You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
val driver =AndroidSqliteDriver(MyCoolStore.Schema, this, null)
val db =MyCoolStore(driver)
db.bugQueries.upsert(
col0 ="a",
col1 ="b",
col2 =true,
col3 =123
)
SqlDelight throws up:
Caused by: java.lang.IllegalArgumentException: Cannot bind argument at index 5 because the index is out of range. The statement has 4 parameters.
at android.database.sqlite.SQLiteProgram.bind(SQLiteProgram.java:212)
at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:166)
at androidx.sqlite.db.framework.FrameworkSQLiteProgram.bindString(FrameworkSQLiteProgram.java:50)
at com.squareup.sqldelight.android.AndroidPreparedStatement.bindString(AndroidSqliteDriver.kt:189)
at com.littledot.androidbugreport.app.BugQueriesImpl$upsert$1.invoke(MyCoolStoreImpl.kt:118)
at com.littledot.androidbugreport.app.BugQueriesImpl$upsert$1.invoke(MyCoolStoreImpl.kt:92)
at com.squareup.sqldelight.android.AndroidSqliteDriver.execute(AndroidSqliteDriver.kt:120)
at com.squareup.sqldelight.android.AndroidSqliteDriver.execute(AndroidSqliteDriver.kt:136)
at com.littledot.androidbugreport.app.BugQueriesImpl.upsert(MyCoolStoreImpl.kt:102)
at com.littledot.androidbugreport.MainActivity.onCreate(MainActivity.kt:17)
at com.squareup.sqldelight.android.AndroidSqliteDriver.execute(AndroidSqliteDriver.kt:120)
at com.squareup.sqldelight.android.AndroidSqliteDriver.execute(AndroidSqliteDriver.kt:136)
at com.littledot.androidbugreport.app.BugQueriesImpl.upsert(MyCoolStoreImpl.kt:102)
at com.littledot.androidbugreport.MainActivity.onCreate(MainActivity.kt:17)
2
java.lang.ArrayIndexOutOfBoundsException: 2
at org.sqlite.core.CorePreparedStatement.batch(CorePreparedStatement.java:121)
at org.sqlite.jdbc3.JDBC3PreparedStatement.setLong(JDBC3PreparedStatement.java:331)
at com.squareup.sqldelight.sqlite.driver.SqliteJdbcPreparedStatement.bindLong(JdbcDriver.kt:123)
.....
at com.example.BugQueriesImpl.upsert(BugDatabaseImpl.kt:65)
at com.example.BugQueriesTest$1$1$1.invoke(BugQueriesTest.kt:18)
Generated upsert method:
override fun upsert(serverId: String, id: Long) {
driver.execute(15499350, """
|UPDATE Bug
| SET serverId = ?
| WHERE id = ?;
|
| INSERT OR IGNORE INTO Bug(
| id, serverId
| )
| VALUES
| (
| ?, ?
| );
""".trimMargin(), 4) {
bindString(1, serverId)
bindLong(2, id)
bindLong(3, id)
bindString(4, serverId)
}
notifyQueries(15499350, {database.bugQueries.selectAll})
}
Runtime Environment
SQLDelight version: 1.4.0
Application OS: Android
Describe the bug
I'm trying to convert a separate update + insert queries into a single upsert query using the Grouping Statement feature.
Consider the following schema:
When running the following query like so
SqlDelight throws up:
BugQueriesImpl.upsert:
Repro: Run project https://gitlab.com/littledot/android-bug-report
The text was updated successfully, but these errors were encountered: