-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 4714 postgresql alter column nullability (#4831)
* Change postgresql grammar Create a rule to express the not null constraint * Update AlterTableAlterColumnMixin Find the not null column constraint SET or DROP and set nullability on QueryColumn * Update TableInterfaceGenerator If the QueryColumn has been modified the nullable flag will be will either true or false Override the columnDef nullable type * Add migration tests Testing that the data class properties have update nullable types and unmodified remain the same * Refactor applyTo The QueryColumn nullable property can be null, true or false We can always assign queryColumn.copy(nullable = nullableColumn) when the column matches
- Loading branch information
Showing
9 changed files
with
89 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
6 changes: 6 additions & 0 deletions
6
...compiler/src/test/migration-interface-fixtures/alter-table-alter-column/com/example/1.sqm
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CREATE TABLE test ( | ||
first TEXT NOT NULL, | ||
second INTEGER, | ||
third TEXT NOT NULL, | ||
fourth INTEGER | ||
); |
2 changes: 2 additions & 0 deletions
2
...compiler/src/test/migration-interface-fixtures/alter-table-alter-column/com/example/2.sqm
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE test ALTER COLUMN first DROP NOT NULL; | ||
ALTER TABLE test ALTER COLUMN second SET NOT NULL; |
2 changes: 2 additions & 0 deletions
2
...mpiler/src/test/migration-interface-fixtures/alter-table-alter-column/com/example/Data.sq
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
insertFirst: | ||
INSERT INTO test (first, second, third, fourth) VALUES (?, ?, ?, ?); |
30 changes: 30 additions & 0 deletions
30
...t/migration-interface-fixtures/alter-table-alter-column/output/com/example/DataQueries.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.example | ||
|
||
import app.cash.sqldelight.TransacterImpl | ||
import app.cash.sqldelight.db.SqlDriver | ||
import app.cash.sqldelight.driver.jdbc.JdbcPreparedStatement | ||
import kotlin.Int | ||
import kotlin.String | ||
|
||
public class DataQueries( | ||
driver: SqlDriver, | ||
) : TransacterImpl(driver) { | ||
public fun insertFirst( | ||
first: String?, | ||
second: Int, | ||
third: String, | ||
fourth: Int?, | ||
) { | ||
driver.execute(-2_134_278_654, | ||
"""INSERT INTO test (first, second, third, fourth) VALUES (?, ?, ?, ?)""", 4) { | ||
check(this is JdbcPreparedStatement) | ||
bindString(0, first) | ||
bindInt(1, second) | ||
bindString(2, third) | ||
bindInt(3, fourth) | ||
} | ||
notifyQueries(-2_134_278_654) { emit -> | ||
emit("test") | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...src/test/migration-interface-fixtures/alter-table-alter-column/output/com/example/Test.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.example | ||
|
||
import kotlin.Int | ||
import kotlin.String | ||
|
||
public data class Test( | ||
public val first: String?, | ||
public val second: Int, | ||
public val third: String, | ||
public val fourth: Int?, | ||
) |