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

Using query variable ?1 leads to a compilation error #2759

Closed
dimsuz opened this issue Jan 3, 2022 · 0 comments · Fixed by #2764
Closed

Using query variable ?1 leads to a compilation error #2759

dimsuz opened this issue Jan 3, 2022 · 0 comments · Fixed by #2764
Labels

Comments

@dimsuz
Copy link

dimsuz commented Jan 3, 2022

SQLDelight Version

1.5.3

Operating System

Linux

Gradle Version

7.3.3

Kotlin Version

1.6.10

AGP Version

4.2.2

Describe the Bug

This query

CREATE TABLE Player(
  id TEXT PRIMARY KEY,
  username TEXT NOT NULL,
  email TEXT NOT NULL
);

select_default_with_query:
SELECT *
FROM Player
WHERE username LIKE ('%' || ?1 || '%') OR email LIKE ('%' || ?1 || '%');

generates the following code in DatabaseImpl.kt:

  public override fun select_default_with_query(`value`: String): Query<Player> =
      select_default_with_query(value_) { id, username, email ->
    Player(
      id,
      username,
      email
    )
  }

Which fails to compile with:

e: /path/to/kmm/project/shared/feature/subscription/build/generated/sqldelight/code/Database/commonMain/ru/dimsuz/freeaway/forum/admin/subscription/subscription/DatabaseImpl.kt: (116, 33): Unresolved reference: value_

This is a KMM project.
If you'll have trouble quickly reproducing, ping, I'll try to create a minimal project.

Stacktrace

No response

Gradle Build Script

import org.jetbrains.compose.compose

plugins {
  id("com.android.library")
  kotlin("multiplatform")
  kotlin("plugin.serialization")
  id("org.jetbrains.compose")
  id("com.squareup.sqldelight") version "1.5.3"
}

sqldelight {
  database("Database") {
    packageName = "ru.dimsuz.kmm.test"
  }
}

kotlin {
  android()
  jvm("desktop")

  sourceSets {
    all {
      languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi")
      languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
    }
    named("commonMain") {
      dependencies {
        api(compose.runtime)
        api(compose.foundation)
        api(compose.material)
        api(project(":shared:foundation"))
        // DATA
        implementation("com.squareup.okhttp3:okhttp:4.9.1")
        implementation("com.squareup.okhttp3:logging-interceptor:4.9.1")
        implementation("com.squareup.retrofit2:retrofit:2.9.0")
        implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
        implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0")
      }
    }
    val commonJvmMain by creating {
      dependencies {
      }
    }
    val desktopMain by getting {
      dependsOn(commonJvmMain)
      dependencies {
        implementation("com.squareup.sqldelight:sqlite-driver:1.5.3")
      }
    }
    val androidMain by getting {
      dependsOn(commonJvmMain)
      dependencies {
        api("androidx.appcompat:appcompat:1.4.0")
        api("androidx.core:core-ktx:1.7.0")
        implementation("com.squareup.sqldelight:android-driver:1.5.3")
      }
    }
  }
}

android {
  compileSdkVersion(31)

  defaultConfig {
    minSdkVersion(21)
    targetSdkVersion(31)
    versionCode = 1
    versionName = "1.0"
  }

  compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
  }

  sourceSets {
    named("main") {
      manifest.srcFile("src/androidMain/AndroidManifest.xml")
      res.srcDirs("src/androidMain/res")
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant