ddb
ddb copied to clipboard
Some problems with Nullable
There are some problems with the Nullable implementation in ddb:
- The way
Variant
is used, with avoid*
it doesn't compile. It think it's becausenull
has its own type now. This is easily fixable, replacevoid*
withtypeof(null)
-
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 tonull
and an empty string. One the other hand databases usually do make a difference between the empty string andNULL
. I guess it's possible to check.ptr
if a string isnull
or not, but that will result in a different API for checking if something isnull
or not - 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 astd.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.