Christian Manning wrote:
Hi,
I'm a second year student at De Montfort University studying Computer
Science. I am very much interested in working on the database API idea
that is proposed at
http://prowiki.org/wiki4d/wiki.cgi?GSOC_2011_Ideas#DatabaseAPI (I was
also quite interested in the containers idea, but it looks like someone
else wants to do that)

I have limited experience with database libraries but have begun to
study the JDBC API (in my small amount of spare time only as term
doesn't finish for another 2 weeks for me and I still have assignments).

Has this idea/project been assigned a mentor? I'd like to ask them and
the list, what's the best thing for me to do right now to prepare for this?

Thanks
Chris

I'm at finishing stage of my PostgreSQL client, written entirely in D. I will post sources in few days.

Before adding database support to Phobos, there are few important issues which obviously need further discussion. One of this issues are handling NULL values - essential thing in relational databases.

Although, there were some efforts to introduce standard Nullable or Optional type, they were aborted.

Currently I'm using this simple definition:

struct Nullable(T)
{
    Algebraic!(T, void*) Nullable;
    alias Nullable this;

    bool hasValue()
    {
        return cast(bool)Nullable.peek!(T);
    }

    bool isNull()
    {
        return cast(bool)!Nullable.peek!(T);
    }

    string toString()
    {
        T* t = Nullable.peek!T;
        return t ? to!string(*t) : "null";
    }
}

It flawlessy cooperates with Variant, which - I think - should officially support nulls as well. I would propose that standard Nullable type, should be a subtype of Algebraic union as above.

During writing my PostgreSQL interface, I also had some problems with Variant and std.conv.to functions. Currently std.conv doesn't support Variants, f.i. when using to!Variant(5), there are more than one toImpl match.

In case of DB api, Variants are also essential, because field types returned by database server aren't known at compile time.

To sum up, Phobos need some additional changes for database support, mainly addition of Nullable.

Reply via email to