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

Add alterType and update index.d.ts for alter function #4967

Merged
merged 6 commits into from Jan 27, 2022

Conversation

OlivierCavadenti
Copy link
Collaborator

@OlivierCavadenti OlivierCavadenti commented Jan 25, 2022

@OlivierCavadenti
Copy link
Collaborator Author

@intech do you think I can do something for cockroachdb test ? Or I need to revert for now ?

@intech
Copy link
Contributor

intech commented Jan 25, 2022

@intech do you think I can do something for cockroachdb test ? Or I need to revert for now ?

Quickly studied the error and can not say how to get around it. I'll ask the cockroachdb engineers for advice and get back.

@intech
Copy link
Contributor

intech commented Jan 26, 2022

@OlivierCavadenti This column change is not yet supported cockroachdb/cockroach#47636
And cockroachdb/cockroach#49329 (comment) for other test case

@kibertoad
Copy link
Collaborator

wait, wasn't the whole idea of the change to avoid altering nullability? or crdb doesn't support such change even without toucing nullability?

@intech
Copy link
Contributor

intech commented Jan 26, 2022

@kibertoad I don't really understand the real application of this functionality, which I wrote about in the original issue on another project using knex.
Now the error occurs on this query:

alter table "primary_table_null" alter column "id_not_nullable_primary" type integer using ("id_not_nullable_primary"::integer);

Why do we need to change the column type to int if we already have int when creating the table?

create table "primary_table_null" ("id_not_nullable_primary" integer not null);

@OlivierCavadenti @kibertoad Could you please explain to me the application of these queries?

@kibertoad
Copy link
Collaborator

@intech I think what happens there is that since knex does not know what is the current type of the column, it uses the one specified in alter command. To address that we probably need additional parameter alterType, which omits type change if set.

types/index.d.ts Outdated Show resolved Hide resolved
@OlivierCavadenti OlivierCavadenti changed the title Dont skip tests for CockroachDB Add alterType and update index.d.ts for alter function Jan 26, 2022
@@ -2210,7 +2210,7 @@ export declare namespace Knex {
notNullable(): ColumnBuilder;
nullable(): ColumnBuilder;
comment(value: string): ColumnBuilder;
alter(): ColumnBuilder;
alter(options: Readonly<{alterNullable?: boolean, alterType?: boolean}>): ColumnBuilder;
Copy link

Choose a reason for hiding this comment

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

this is breaking for TS users. the parameter was not there, now its required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, sorry, just fixed and merged here : #4996

Copy link
Collaborator

Choose a reason for hiding this comment

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

will publish hotfix shortly

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

Successfully merging this pull request may close these issues.

None yet

4 participants