Repository: sqldelight/sqldelight

Issue #4515: SQLDelight generates queries with identifiers with incorrect minus sign
Created: 2023-08-10T18:53:00Z
SQLDelight Version
2.0.0
Operating System
macOS Ventura
Gradle Version
8.0.2
Kotlin Version
1.8.10
Dialect
SQLite
AGP Version
No response
Describe the Bug
The identifier for the queries in the generated source code is generated incorrectly if it is negative.
Anytime a generate a query that results in a negative identifier SQLDelight uses an incorrect minus sign for the identifier creating a compile error. My workaround is to change the name of the query until I get a positive identifier.

This file (I changed the extension from .sq to .txt to make GitHub happy) always causes said issue:
AppDatabase.txt
The generated query uses the character "MINUS SIGN" but valid Kotlin uses "HYPHEN-MINUS"
Stacktrace
No response
Gradle Build Script
No response

Duplicate issue #4547: Generates "queries" code is invalid
Created: 2023-08-20T09:10:50Z
SQLDelight Version
2.0.0
Operating System
Windows 11
Gradle Version
8.2
Kotlin Version
1.9.0
Dialect
SQLite
AGP Version
8.0.0-alpha16
Describe the Bug
Every generated queries file has errors similar to the ones below. Ive used SqlDelight for many years, but this is the first time Im using 2.0.0, and its in a different project (so no migration).
Running on: Android Studio Hedgehog | 2023.1.1 Canary 16
Using jetpack compose.

The .sq file is very basic:
import domain.aggregate.common.value.Currency;
import domain.aggregate.common.value.Id;
import domain.aggregate.profile.model.Theme;

CREATE TABLE profileSql (
    id TEXT AS Id NOT NULL PRIMARY KEY,
    theme TEXT AS Theme NOT NULL,
    currency TEXT AS Currency NOT NULL,
    selectedAccountId TEXT AS Id,
    FOREIGN KEY (selectedAccountId) REFERENCES accountSql(id)
);

find:
SELECT * FROM profileSql WHERE id=?;

all:
SELECT * FROM profileSql;

save:
INSERT OR REPLACE INTO profileSql VALUES ?;

delete:
DELETE FROM profileSql WHERE id=?;


Stacktrace
No response
Gradle Build Script
Global build.gradle:

plugins {
    alias libs.plugins.kotlin.jvm apply false
    alias libs.plugins.kotlin.android apply false
    alias libs.plugins.kotlin.multiplatform apply false
    alias libs.plugins.kotlin.serialization apply false
    alias libs.plugins.kotlin.ktor apply false

    alias libs.plugins.android.library apply false
    alias libs.plugins.android.application apply false

    alias libs.plugins.google.services apply false
    alias libs.plugins.firebase.crashlytics apply false

    alias libs.plugins.sqldelight apply false
}

Database build.gradle:

plugins {
    id 'preset-multiplatform-android'

    id 'app.cash.sqldelight'
}

kotlin {
    sourceSets {
        commonMain.dependencies {
            implementation "app.cash.sqldelight:coroutines-extensions:2.0.0"
        }

        androidMain.dependencies {
            implementation "app.cash.sqldelight:android-driver:2.0.0"
        }
    }
}

sqldelight {
    databases {
        Database {
            packageName = "io.xyz"
        }
    }
}

preset-multiplatfrom-android:

plugins {
    id 'org.jetbrains.kotlin.multiplatform'

    id 'com.android.library'
}

android {
    namespace xyz

    defaultConfig {
        def config = libs.versions.config

        compileSdk config.compileSdk.get() as int
        targetSdk config.targetSdk.get() as int
        minSdk config.minSdk.get() as int

        versionName config.versionName.get()
        versionCode config.versionCode.get() as int
    }

    buildTypes {
        debug
        release
        staging
        benchmark
    }
}

kotlin {
    androidTarget()
}

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

Closing comment (2023-08-20T12:01:26Z): Seems like a duplicate of #4515, Im also Swedish :) Closing!