New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(postgresql): add primaryKey option for uuid #5212
fix(postgresql): add primaryKey option for uuid #5212
Conversation
The cockroach dialect needs to be able to set the default value to UUID PRIMARY KEY DEFAULT gen_random_uuid() |
'SELECT c.oid FROM pg_catalog.pg_class c WHERE c.relname = ?', | ||
[table_name] | ||
) | ||
.then((res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use instead await notation
|
||
return knex | ||
.raw( | ||
`select c.column_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we select and test tolumn type too ?
I also added docs in knex/documentation#419 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TS types also need to be updated
@kibertoad thanks for the hint, types have been added in 46b8a69 I also realised that i had forgotten to register the new CockroachDB unit tests which has now also been fixed. |
Thank you! I'll publish new version tonight. |
Adds support for creating a uuid field as primary key directly in a create statement using
uuid('id', { primaryKey: true })
for PostgreSQL dialects.For now the option is only implemented for PostgreSQL dialects since it should work for all of them and it's only really an issue for CockroachDB.
As far as i can tell, using
uuid('id', { primaryKey: true }).primary()
would still work if you need to support other dialects (theprimary()
would just generate a no-op alter statement).It's getting late here, so i'll add a docs PR tomorrow. Please let me know if the integration test (or anything else) is too hacky and i'll improve on it.
Fixes #5211
Docs: knex/documentation#419