IrenejMarc/dpq

RelationProxy on structs containing Nullable!SysTime causes compilation error.

Closed this issue · 0 comments

The following code

@relation
struct S {
    @PK @serial int id;
    Nullable!SysTime someTime;
}

void main() {
    // some code, connecting to db
    auto rp = RelationProxy!S(connection);
}

does not compile with the error:

../dpq/source/dpq/connection.d(1641,43): Error: template `std.datetime.systime.SysTime.opCast` does not match any template declaration
../dpq/source/dpq/relationproxy.d(89,33): Error: template instance `dpq.connection.deserialise!(S)` error instantiating
source/app.d(186,12):        instantiated from here: `RelationProxy!(S)`
/usr/bin/dmd failed with exit code 1.

Replacing cast(OType)x.get with x.get.to!OType fixes the issue and probably I will submit a pull request soon if this is fine. Since x is already of MType which is basically a OType with typedefs etc this should not raise any issues.

This happens because SysTime does not have any opCast overloads that accepts a Nullable!SysTime and the only other solution I see is to have a compilation condition that will handle SysTime separately, but I don't think this is a good general solution.