Hi.
Have you ever used these funny types with a question mark in DotNet?
Well, they are called Nullable types and were introduced to provide the ability to set value types to "null", enabling a more natural integration between some datasets (such relational databases) and DotNet world. For instance, relational databases supports the concept of null fields even for integers. By the other hand .Net integers are value types which doesn't have such concept (someone said object/relational type mismatch?). (Just for the records, the syntax type? identifier is a C# shorthand for the full declaration: Nullable identifier).
As I commented out in this post, at Db4o, we are continually pursuing
better platform compliance (be it related to idioms, type system
support, etc.) so some time ago we improved support for nullable types like in the following example
class TestNullableContainer
{
private int? _value;
}
The next logical step was to extend this support to arrays, allowing Db4o to store arrays of nullables. In previous versions (< 7.9) we stored the array successfully but there were no way to retrieve it (instead an exception would be thrown). The problem was that in prior versions we loose the information about "nullableness", i.e, arrays such as int? []items were stored as if they were the "non nullable" counterpart (int []items)
and even though we would successfully retrieve them from database .Net
would just throw when trying to assign the just read object to the
respective field (something like: int? []items = new int[] {1, 2, 3}).
Unfortunately extending nullable support to arrays of nullables proved to be trickier than we expected but after some code rewrite, we finally got it working (please, note that we still have some work to do regarding some not so common array usages scenarios).
To make it easier to spot the differences I've included a sample application that allows you to select a specific Db4o version (starting with 7.1) and run a piece of code against it (it is an adaptation of my last post sample app). You can test it with any number of different Db4o versions and compare the outcome of each one. To use this application simply compile the 2 projects (Db4oTestRunner and NullableArraysTest), then fire Db4oTestRunner and select NullableArraysTest assembly and finally click on "run" button (of course, you can write your own tests :).
Since our goal is to continue improving platform compliance, we'd like to know which improvements regarding platform compliance you'd like to see.
Please, go, download the test application (either from the attached TestNullableArrays.zip file or get it through svn: svn co https://source.db4o.com/db4o/trunk/sandbox/Adriano/Blogs/), and play with it.
Best
Adriano