Skip to content

Some problems with Nullable #51

@jacob-carlborg

Description

@jacob-carlborg

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions