JSONB (JSON) and UUID column support? [.drift] [Postgres]
Is your feature request related to a problem? Please describe. I am using drift_postgres and want to create JSONB (preferably over JSON) and also UUID columns in .drift file SQL definitions.
Describe the solution you'd like
CREATE TABLE IF NOT EXISTS [members] (
[id] UUID PRIMARY KEY NOT NULL, -- <-- UUID results in double
[first_name] TEXT NOT NULL,
[middle_name] TEXT,
[last_name] TEXT NOT NULL,
[email] TEXT,
[phone] TEXT,
[address] JSONB, -- <-- JSONB results in double
[created] TIMESTAMP NOT NULL,
[updated] TIMESTAMP NOT NULL
);
This .drift SQL results in double typed columns:
late final GeneratedColumn<double> id = GeneratedColumn<double>(
'id', aliasedName, false,
type: DriftSqlType.double,
requiredDuringInsert: true,
$customConstraints: 'PRIMARY KEY NOT NULL');
...
late final GeneratedColumn<double> address = GeneratedColumn<double>(
'address', aliasedName, true,
type: DriftSqlType.double,
requiredDuringInsert: false,
$customConstraints: '');
I also tried JSON:
CREATE TABLE IF NOT EXISTS [members] (
...
[address] JSON, -- <-- results in error
...
);
and received the following build error:
line 8, column 19: Expected a JSON KEY constraint
╷
8 │ [address] JSON,
│ ^
╵
generated on line 2674 of package:sqlparser-0.33.0/lib/src/reader/parser.dart.
But I would prefer JSONB as that is now the new, "comparable" PostgreSQL JSON type.
I think I have to just use manual Dart Table definitions for now for Postgres.
Thanks!
Drift files are targeting the sqlite3 dialect only at the moment, but you can use this syntax to use custom types. I agree that having builtin support for custom types under their name would be nice though.