-
Notifications
You must be signed in to change notification settings - Fork 510
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 4837 alter table alter column #4846
Merged
AlecKazakova
merged 7 commits into
cashapp:master
from
griffio:fix-4837-alter-table-alter-column
Nov 30, 2023
Merged
Fix 4837 alter table alter column #4846
AlecKazakova
merged 7 commits into
cashapp:master
from
griffio:fix-4837-alter-table-alter-column
Nov 30, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
griffio
force-pushed
the
fix-4837-alter-table-alter-column
branch
2 times, most recently
from
November 28, 2023 20:54
ec77ff5
to
6991e82
Compare
…th TableInterfaceGenerator. getColumnConstraintList - use create table constraints - nullability is override in queryColumn getColumnName - use alter table column name getColumnType - use alter table column data type if present or use create table column def getJavadoc - use create table defaults - not used
Add column and expect type to be migrated from Int (Integer) to Long (BIGINT)
Second version to enable passing tests TODO - improvements
Changing the column type must propagate the existing not null/null constraint
Change fifth column to nullable Change fifth column to BIGINT (Long) Expect Long?
getColumnConstraintList return null seems to work as is not used
griffio
force-pushed
the
fix-4837-alter-table-alter-column
branch
from
November 29, 2023 15:43
14fcf7c
to
19e39bc
Compare
reinstate after testing
AlecKazakova
approved these changes
Nov 30, 2023
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.
looks great, thank you!
hfhbd
pushed a commit
that referenced
this pull request
Apr 2, 2024
* AlterTableAlterColumnMixin extends SqlColumnDef to allow operating with TableInterfaceGenerator. getColumnConstraintList - use create table constraints - nullability is override in queryColumn getColumnName - use alter table column name getColumnType - use alter table column data type if present or use create table column def getJavadoc - use create table defaults - not used * AlterTableAlterColumnMixin tests migration Add column and expect type to be migrated from Int (Integer) to Long (BIGINT) * Fix the null elements Second version to enable passing tests TODO - improvements * Propagate the nullable type Changing the column type must propagate the existing not null/null constraint * update tests Change fifth column to nullable Change fifth column to BIGINT (Long) Expect Long? * AlterTableAlterColumnMixin columnConstraintList getColumnConstraintList return null seems to work as is not used * getColumnConstraintList returns constraints reinstate after testing
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #4837
🚧 🐘 🍔 Working on fix
Allow AlterTableAlterColumnMixin extends SqlColumnDef to provide operations to
TableInterfaceGenerator
as it now becomes aColumnDefMixin
source - however it only seems viable for Column Type changesOverride
SqlColumnDef
members ( use thecolumn_type
declared in the ALTER TABLE or existing SqlColumnDef declared in CREATE TABLE ) to fall back to the current values if they are not being altered. Onlycolumn_type
andcolumn_name
can be used with SqlColumnDef. ColumnConstraints are not used to drop/set nullability (use query column nullable) as there is no matching clause in ALTER TABLE.FIXED - If a migration step 1 is
ALTER TABLE test ALTER COLUMN first DROP NOT NULL
and step 2 isALTER TABLE test ALTER COLUMN first TYPE BIGINT;
changing the type propagates the same NOT NULL/NULL - keep the current queryColumn.nullable value when not anull
value - means it was set in another migration and queryColumn propagates the correct nullabilitye.g
queryColumn.copy(element = alterColumnTable, nullable = nullableColumn ?: queryColumn.nullable)
🦺 Performed more testing of local snapshot with column type changes and nullability changes
1.sqm
2.sqm
3.sqm
4.sqm
5.sqm
results in