ddb icon indicating copy to clipboard operation
ddb copied to clipboard

Some problems with Nullable

Open jacob-carlborg opened this issue 8 years ago • 0 comments

There are some problems with the Nullable implementation in ddb:

  1. The way Variant is used, with a void* it doesn't compile. It think it's because null has its own type now. This is easily fixable, replace void* with typeof(null)
  2. Nullable doesn't allow to store types that are already nullable. This might cause a problem for strings. Since in D there's no practical difference compared to null and an empty string. One the other hand databases usually do make a difference between the empty string and NULL. I guess it's possible to check .ptr if a string is null or not, but that will result in a different API for checking if something is null or not
  3. It's a bit wasteful to use a pointer (8 bytes on 64bit) to indicate if a value is present or not. A Nullable!(bool) has the size of 16 while a std.typecons.Nullable!(bool) has the size 2

Thoughts, is this something with could change? We could just go with std.typecons.Nullable, the difference is that it's not possible to assign null to std.typecons.Nullable, it has a nullify method instead.

jacob-carlborg avatar Feb 10 '16 07:02 jacob-carlborg