Mohammed Toufeeq Ahamed
09/26/2023, 6:04 PMsqldelight
with postgres for ktor server, it turns out that sqldelight doesn't support `Postgres Extension`s, I want to have a non-null column with UUID as default, which is possible with uuid-ossp
in postgres. Is ther any way that I will be able to set this up with sqldelight?leonhardt
09/26/2023, 9:22 PMGEN_RANDOM_UUID()
instead of UUID_GENERATE_V4()
just works.
Beyond that I'm subscribed to this GitHub issue for updates on postgres extensions in case it's ever supported. You might also want to chime in on this discussion where @griffio has asked for input to prioritize presently unsupported postgres features.Mohammed Toufeeq Ahamed
09/27/2023, 6:02 AMCREATE TABLE IF NOT EXISTS user(
id UUID PRIMARY KEY NOT NULL GEN_RANDOM_UUID(),
name TEXT NOT NULL UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
);
Thanks for pointing to the issue, hope extensions are supported soon.griffio
09/27/2023, 8:59 AMCREATE TABLE IF NOT EXISTS "user"(
id UUID PRIMARY KEY NOT NULL DEFAULT (gen_random_uuid()),
name TEXT NOT NULL UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
The user
is a reserved word in Postgres, remove comma at the end of CURRENT_TIMESTAMP and gen_random_uuid()
in parentheses for now - there is an issue with function calls in CREATE TABLE.
gen_random_uuid
is built in from PostgreSQL 13
However, I have a PR for CREATE EXTENSION, but the problem is that extensions define new functions. We can’t know about or define every possible extension function available to PostgreSQL.
Once CREATE EXTENSION is available it would have to be down to the user to create an extended custom dialect to add in the functions for the extensions e.g https://github.com/cashapp/sqldelight/tree/master/sqldelight-gradle-plugin/src/test/custom-dialectMohammed Toufeeq Ahamed
09/27/2023, 9:22 AMleonhardt
09/28/2023, 3:10 AMOnce CREATE EXTENSION is available it would have to be down to the user to create an extended custom dialect to add in the functions for the extensions@griffio that sounds like a great solution