Skip to content
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 typing deferrable and withkeyName should not be in ColumnBuilder #4600

Merged
merged 7 commits into from
Aug 7, 2021

Conversation

zeotuan
Copy link
Contributor

@zeotuan zeotuan commented Aug 1, 2021

I came across this PR: #3556. since it hasn't been actived for a long time so i want to conttinue it and also to fix my last Pull Request where i also put deferrable inside ColumnBuilder

@kibertoad
Copy link
Collaborator

Can you also add a test for it?

types/index.d.ts Outdated Show resolved Hide resolved
@zeotuan
Copy link
Contributor Author

zeotuan commented Aug 1, 2021

Can you also add a test for it?

Yeah sure

@zeotuan
Copy link
Contributor Author

zeotuan commented Aug 1, 2021

@kibertoad I need help with writing test though. how should i write tsd test for this? Thank you

@kibertoad
Copy link
Collaborator

kibertoad commented Aug 1, 2021

@zeotuan I would simply invoke a builder chain that used to throw a type error in the past, in a test. Since from my understanding this particular PR adds support for this method for more different builder cases, using several different chains would be the best.
I don't think there will be any actual assertions in new test code, just some code that wouldn't have compiled in the past.

types/index.d.ts Outdated Show resolved Hide resolved
Comment on lines 71 to 79
knexInstance.schema.createTable('testTable',(table) => {
table.foreign('fkey_three').references('non_exist.id').withKeyName('non_for1').deferrable('deferred');
table.foreign('fkey_threee').references('non_exist.id').deferrable('deferred').withKeyName('non_for2');
table.integer('num').references('non_exist.id').deferrable('immediate').withKeyName('non_for3');
table.integer('num').references('non_exist.id').withKeyName('non_for4').deferrable('deferred').onDelete('CASCADE');
table.integer('num').references('non_exist.id').withKeyName('non_for5').deferrable('deferred').onDelete('CASCADE');
table.integer('num').references('id').inTable('non_exist').withKeyName('non_for6').deferrable('deferred').onDelete('CASCADE');
table.integer('num').references('id').withKeyName('non_for7').deferrable('deferred').inTable('non_exist').onDelete('CASCADE');
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kibertoad test added. Should this test be here or should we add a different test file for this type of test?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is good!

@zeotuan zeotuan requested a review from kibertoad August 3, 2021 10:38
@zeotuan
Copy link
Contributor Author

zeotuan commented Aug 3, 2021

@kibertoad This should be in a seperate issue but i think we only support onDelete and onUpdate with foreign and references but the documentation and our type suggest that we also support onUpdate and onDelete on ColumnBuilder.

@kibertoad kibertoad merged commit 4ff3a92 into knex:master Aug 7, 2021
@kibertoad
Copy link
Collaborator

Thank you! Could you create an issue for the remaining problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants