buggins / ddbc

DDBC is DB Connector for D language (similar to JDBC)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

postgresql: support enum types

zhaopuming opened this issue · comments

When I query database with enum columns, this exception throws:

ddbc.core.SQLException@/home/sdev/.dub/packages/ddbc-0.3.7/ddbc/source/ddbc/drivers/pgsqlddbc.d(562): Unsupported column type 16451

where 16451 is a custom defined enum type, with something like:

create type status as enum ('received', 'rejected', 'sent', 'accepted');

Can you add support for these enum types?

currently adding this hack in fillData() works for me:

if (t > 10000) { // assuming custom type id are bigger than 10000
    v[col] = s;
} else switch (t) {
    case INT4OID:
        v[col] = parse!int(s);
    // ....
}

But I also found that numeric type (NUMERICOID=1700) is also not supported, along with other types.
Do you consider adding a custom parser API for people to deal with these types?