Support empty strings for DEFAULT
Closed this issue · 2 comments
ivasilov commented
Hello,
I would like to be able to set an empty string as default value:
export const someTable = defineTable({
id: uuid().primaryKey(),
name: characterVarying().notNull().default(''),
});
This currently generates the following invalid SQL (found it through logging):
"CREATE TABLE some_table (
id uuid PRIMARY KEY,
name character varying NOT NULL DEFAULT
)"
which is invalid SQL (it should be NOT NULL DEFAULT ''
) and it throws a Error: syntax error at or near ")"
.
martijndeh commented
Yea this isn't all too clear yet. You have to provide a raw SQL string e.g. .default("''")
. Can you confirm this works?
martijndeh commented
Assuming this is the case. In a future version you probably need to do something like .default(new RawSql(..))
so it's a bit more explicit and strings should be wrapped (not sure if a parameter can be used).