-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New test for MigrationQueryTest for Postgresql - not relevant for Sqlite as can't alter table to add primary keys Add tests for compiler generation for single and compound primary keys
- Loading branch information
Showing
7 changed files
with
93 additions
and
0 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
9 changes: 9 additions & 0 deletions
9
...mpiler/src/test/migration-interface-fixtures/alter-table-add-constraint/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,9 @@ | ||
CREATE TABLE TestSingle( | ||
first INTEGER, | ||
second TEXT | ||
); | ||
|
||
CREATE TABLE TestCompound ( | ||
first INTEGER, | ||
second TEXT | ||
); |
3 changes: 3 additions & 0 deletions
3
...mpiler/src/test/migration-interface-fixtures/alter-table-add-constraint/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,3 @@ | ||
ALTER TABLE TestSingle ADD PRIMARY KEY (first); | ||
ALTER TABLE TestCompound ADD CONSTRAINT pk_first_second PRIMARY KEY (first, second); | ||
|
8 changes: 8 additions & 0 deletions
8
...iler/src/test/migration-interface-fixtures/alter-table-add-constraint/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,8 @@ | ||
selectSingle: | ||
SELECT * | ||
FROM TestSingle; | ||
|
||
selectCompound: | ||
SELECT * | ||
FROM TestCompound; | ||
|
51 changes: 51 additions & 0 deletions
51
...migration-interface-fixtures/alter-table-add-constraint/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,51 @@ | ||
package com.example | ||
|
||
import app.cash.sqldelight.Query | ||
import app.cash.sqldelight.TransacterImpl | ||
import app.cash.sqldelight.db.SqlDriver | ||
import app.cash.sqldelight.driver.jdbc.JdbcCursor | ||
import kotlin.Any | ||
import kotlin.Int | ||
import kotlin.String | ||
|
||
public class DataQueries( | ||
driver: SqlDriver, | ||
) : TransacterImpl(driver) { | ||
public fun <T : Any> selectSingle(mapper: (first: Int, second: String?) -> T): Query<T> = | ||
Query(-79_317_191, arrayOf("TestSingle"), driver, "Data.sq", "selectSingle", """ | ||
|SELECT * | ||
|FROM TestSingle | ||
""".trimMargin()) { cursor -> | ||
check(cursor is JdbcCursor) | ||
mapper( | ||
cursor.getInt(0)!!, | ||
cursor.getString(1) | ||
) | ||
} | ||
|
||
public fun selectSingle(): Query<TestSingle> = selectSingle { first, second -> | ||
TestSingle( | ||
first, | ||
second | ||
) | ||
} | ||
|
||
public fun <T : Any> selectCompound(mapper: (first: Int, second: String) -> T): Query<T> = | ||
Query(-19_725_220, arrayOf("TestCompound"), driver, "Data.sq", "selectCompound", """ | ||
|SELECT * | ||
|FROM TestCompound | ||
""".trimMargin()) { cursor -> | ||
check(cursor is JdbcCursor) | ||
mapper( | ||
cursor.getInt(0)!!, | ||
cursor.getString(1)!! | ||
) | ||
} | ||
|
||
public fun selectCompound(): Query<TestCompound> = selectCompound { first, second -> | ||
TestCompound( | ||
first, | ||
second | ||
) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...igration-interface-fixtures/alter-table-add-constraint/output/com/example/TestCompound.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,9 @@ | ||
package com.example | ||
|
||
import kotlin.Int | ||
import kotlin.String | ||
|
||
public data class TestCompound( | ||
public val first: Int, | ||
public val second: String, | ||
) |
9 changes: 9 additions & 0 deletions
9
.../migration-interface-fixtures/alter-table-add-constraint/output/com/example/TestSingle.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,9 @@ | ||
package com.example | ||
|
||
import kotlin.Int | ||
import kotlin.String | ||
|
||
public data class TestSingle( | ||
public val first: Int, | ||
public val second: String?, | ||
) |