wesp
wesp
DTDrizzle Team
Created by wesp on 10/24/2024 in #help
Is it possible to generate a default value concatenating with NEXTVAL?
It seems this can be done with sql.raw
function generateNumber(prefix: string, sequence: PgSequence) {
return sql.raw(`'${prefix}' || NEXTVAL('${sequence.seqName}')`);
}
function generateNumber(prefix: string, sequence: PgSequence) {
return sql.raw(`'${prefix}' || NEXTVAL('${sequence.seqName}')`);
}
3 replies
DTDrizzle Team
Created by wesp on 10/24/2024 in #help
Is it possible to generate a default value concatenating with NEXTVAL?
It looks like this is possible via the sql operator
number: varchar({ length: 15 }).default(sql`'S' || NEXTVAL('${sessionNumberSequence.seqName}')`),
number: varchar({ length: 15 }).default(sql`'S' || NEXTVAL('${sessionNumberSequence.seqName}')`),
But if I try to inject the sequence name I get the following error from drizzle-kit generate
Error: we don't support params for `sql` default values
Error: we don't support params for `sql` default values
3 replies