https://kotlinlang.org logo
Join Slack
Powered by
# squarelibraries
  • a

    andylamax

    08/31/2025, 9:32 AM
    Hi there, I am using SQLDelight and I am trying to setup a dependency between two database (defined with the sqldelight gradle plugin). I followed the documentation and it shows clearly how to do this on a gradle subproject. There are two ways to setup these kind of dependencies
    Copy code
    fun dependency(dependencyProject: Project)
    fun dependency(delegatedProject: DelegatingProjectDependency)
    The issue that I have here is that, the dependencies are defined inside a composite build (not just a subproject). And I am having a hard time getting an instance of that subproject. If anyone can help me how to achieve this, I will greatly appreciate
    h
    • 2
    • 6
  • s

    Shubham Singh

    08/31/2025, 2:14 PM
    Hi everyone, how do we create a persistent DB using SQLDelight on JS? Web Workers driver by default only creates an in-memory DB.
    a
    • 2
    • 1
  • a

    andylamax

    09/02/2025, 1:57 PM
    Hello once again, I am building a hybrid app (with both online and offline support) and I am trying an unorthodox approach of sharing some tables on the client side and the server side The issue is that I need to write an SQL statement that is portable between SQLite (on the client) and MySQL (on the backend) Take the following statement as an example
    Copy code
    CREATE TABLE IF NOT EXISTS ow_core_people(
        uid INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
        name TEXT NOT NULL,
        photo TEXT
    );
    Because AUTO_INCREMENT doesn't work on SQLite, it just works on MySQL but fails on SQLite. Is there a way for SQLDelight to support these multiple syntax and transform them in accordance to the dialect selected?
  • c

    Colton Idle

    09/07/2025, 4:58 AM
    did the compose dialogs library from keith ever ship or is that still coming up?
    s
    z
    +2
    • 5
    • 7
  • u

    ursus

    09/09/2025, 11:30 AM
    When writing
    sqldelight
    kotlin migrations, I need to have atleast a placeholder
    .sqm
    file. This is error prone, as nothing seems to enforce the
    .sqm
    file. Has anyone figured out a way to blow up such state? (
    .kt
    migration present but
    .sqm
    not)
  • s

    Slackbot

    09/10/2025, 10:32 AM
    This message was deleted.
    j
    a
    • 3
    • 2
  • e

    eygraber

    09/12/2025, 6:58 PM
    If anyone has a project using SqlDelight that could test it with sqldelight-androidx-driver it would be very much appreciated 😄 https://kotlinlang.slack.com/archives/C0BJ0GTE2/p1757703433402129
    ☝️ 1
    👀 1
  • c

    Colton Idle

    09/25/2025, 3:39 PM
    Can we re-open this by chance? Hitting this again with detekt 😭 https://github.com/sqldelight/sqldelight/issues/4157
    h
    b
    m
    • 4
    • 4
  • u

    ursus

    09/30/2025, 1:11 PM
    HI, I'm an jvm
    anvil
    user. Now I want to experiment with KMP. I want to keep
    @Inject
    and
    @ContributesBinding..
    in common - and expect-actual them to typealiases of the jvm libs (and therefore have anvil/dagger take effect only on jvm)
    @Inject
    is easy enough
    Copy code
    @Target(
        FUNCTION,
        PROPERTY_GETTER,
        PROPERTY_SETTER,
        CONSTRUCTOR,
        FIELD
    )
    @Retention(RUNTIME)
    @MustBeDocumented
    expect annotation class Inject()
    Copy code
    actual typealias Inject = javax.inject.Inject
    but I'm having trouble with
    @ContributesBinding
    because of all the params. See the full issue in thread
    e
    • 2
    • 5
  • c

    Colton Idle

    09/30/2025, 6:05 PM
    lazyweb: using mockwebserver in an existing project (it already had the dep added). writing a new test with it... now going to import and i see two options
    com.squareup.okhttp3:mockwebserver3:5.1.0
    or
    com.squareup.okhttp3:mockwebserver:5.1.0
    Are my depenedencies setup incorrectly or should i indeed be seeing both options (if so... which to pick)?
    y
    • 2
    • 11
  • u

    ursus

    10/01/2025, 9:45 PM
    I want to encrypt my access tokens at rest, but the decryption being somehow expensive I'm thinking of caching the plain text of access token in memory. Then I remembered to use
    ByteArray
    instead of a `String`so I can deterministically clear the value from memory, because GC blah blah. But, when using
    okhttp
    interceptor to attach a token as
    Copy code
    val tokenString = String(tokenBytes, Charsets.UTF_8) <-----
    val newRequest = request.newBuilder()
        .header("Authorization", "Bearer $tokenString")
        .build()
    then it's a moot point right? Or -- the question -- is there a smarter what of doing this in
    okhttp
    ? Or do I just need to accept the transient token in memory (and therefore holding it as
    ByteArray
    is mostly pointless)?
    j
    c
    • 3
    • 14
  • c

    Colton Idle

    10/08/2025, 8:44 PM
    I've got what I think is a pretty simple setup. I have an androidlibrary module... and a small app module to exercise said library. okhttp is only added to the androidlibrary module.
    ./gradlew androidlibrary:assemble
    is successful, but
    ./gradlew app:assemble
    fails due to
    Copy code
    * What went wrong:
    Execution failed for task ':app:checkDebugDuplicateClasses'.
    > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
       > Duplicate class okhttp3.Address found in modules okhttp-jvm-5.1.0.jar -> okhttp-jvm-5.1.0 (com.squareup.okhttp3:okhttp-jvm:5.1.0) and okhttp-release.aar -> okhttp-release-runtime (com.squareup.okhttp3:okhttp-android:5.1.0)
    seems like something regarding okhttp-jvm and okhttp-android? according to docs, this shouldn't be an issue since im using gradle and not maven?
    e
    • 2
    • 15
  • j

    jessewilson

    10/09/2025, 9:57 PM
    ⚠️ Heads up: OkHttp 5.2.0 is crashing on API levels 21 through 23. We’re cutting OkHttp 5.2.1 to fix. Details here.
    🙏 5
  • c

    Colton Idle

    10/09/2025, 10:16 PM
    Question about okhttps bom. It seems like all of okhttps artifacts are versioned together in lock step. why the bom? from what i can tell, bom seems to be more helpful in situations where artifact versions are all scattered?
    e
    j
    s
    • 4
    • 6
  • e

    eygraber

    10/12/2025, 4:42 PM
    I'm looking into making my SqlDriver use
    QueryResult.AsyncValue
    , not because the driver itself is async, but because I want to use coroutines in my connection pool. Is that "abusing" the system, or a valid use case?
  • e

    eygraber

    10/13/2025, 10:02 PM
    As part of the above, I'm trying to bake in CoroutineDispatcher support directly to the SqlDriver so users don't have to manage that. I'm running into issues with
    transaction
    though, because it doesn't like the transaction escaping the thread it is started on, which is what happens with the dispatcher support (newTransaction, execute, and executeQuery use withContext to switch into the proper dispatcher). Is there any way to hook into the transacter to support this, and if not, is there any chance support for this could get added to SqlDelight?
    h
    • 2
    • 8
  • y

    Yassine Abou

    10/15/2025, 8:25 PM
    Hi everyone, I'm running into a persistent
    no such table: user
    error with SQLDelight on a Kotlin Multiplatform project. I've tried the common solutions like manually calling
    Schema.create(driver)
    , deleting the old database file, and ensuring I'm using a singleton instance for the database, but the problem persists. It seems the schema creation is either not happening or is happening after my first query is executed. Full stacktrace and code in thread 👇🏽
    j
    • 2
    • 3
  • c

    Colton Idle

    10/17/2025, 5:50 PM
    Getting ready to distribute my first android-library, so I'm doing a final check. If I'm using okhttp in my android library (as an implementation dependency) do I need to include keep rules in consumer-rules.pro and proguard-rules.pro? Or since it's an android lib... will all of those proguard rules just work? I keep chasing my tail on this because I'm teetering on whether or not we will proguard our library so its a bit obfuscated (in the finance space so PM/TL really want obfuscation)
    t
    j
    u
    • 4
    • 22
  • y

    Yassine Abou

    10/17/2025, 10:19 PM
    My application uses SQLDelight to save chat history and generated images. This functionality has suddenly stopped working (Everthing works before) . To ensure this wasn't a local issue, I completely deleted my local repository and cloned it again. The problem persists. The app fails with the following errors:
    Copy code
    text
    org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: chats)
    org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: generated_images)
    To reproduce the error: 1. Clone the repository: https://github.com/yassineAbou/LLMS.git 2. Run the composeApp desktop target 3. The errors appear immediately during the build
    j
    • 2
    • 16
  • e

    eygraber

    10/20/2025, 3:53 AM
    PSA for anyone using sqldelight-androidx-driver: I am strongly considering making the driver async (the underlying SQLite APIs are still blocking though). This will allow more efficient integration with the connection pool that I've added to it, as well as make it possible to handle all of the details about dispatching internally, so SQLDelight APIs can be used without worrying about what
    CoroutineDispatcher
    you are using. If you have any thoughts, questions, or concerns, please discuss here
    g
    • 2
    • 2
  • c

    Colton Idle

    10/24/2025, 2:57 PM
    I created new project (from android studio wizard). it defaults to using kotlin 2.0.20. i added okhttp latest as a dep and don't do anything with it, and then i get a somewhat obscure error message, but after bumping to kotlin 2.2.x. the error is resolved. still a noob on this topic. im assuming thats expected? that once any library I use moves to a newer version of kotlin that the consumer must also move to that version (bonus question... as a library author... is it in your best interest to just target 2.0.x instead?)
    j
    e
    • 3
    • 20
  • c

    crowforkotlin

    10/25/2025, 1:34 AM
    As mentioned in the Zipline WASM support discussion, replacing the QuickJS interpreter with Wasm3 or WasmEdge would be the only way to achieve a web-based loader, correct? The current loader module doesn't support the web; it's limited to Android, iOS, and desktop. While I have created a simple program to simulate the effect of dynamically loading a JS plugin, trying to somehow insert a JS file into the existing Zipline files would be quite messy... However, the work involved in replacing the interpreter, if possible, is massive. As for inserting a dynamic JS plugin into the current structure, perhaps a 'web' folder could be created in Zipline's root directory to store the JS, though this JS would likely need to consider encryption. https://github.com/cashapp/zipline/discussions/843 https://github.com/crowforkotlin/compose-multiplatform-web-dynamic-load-js-plugin
    j
    • 2
    • 7
  • m

    maximilianosorich

    11/01/2025, 11:03 PM
    Hello I am getting an error with SQLDelight Browser WASM: WebWorkerException: {"message":"Uncaught SyntaxError: Unexpected token '<'","type":"error"}isTrusted,true overrideMethod@ The build.gradle.kts:
    Copy code
    kotlin {
       @OptIn(ExperimentalWasmDsl::class)
       wasmJs("store") {
          browser {
             commonWebpackConfig {
                outputFileName = "store.js"
             }
          }
          binaries.executable()
       }
    storeMain.dependencies {
       // DB Web worker
       implementation(libs.web.worker.driver)
       implementation(devNpm("copy-webpack-plugin", "9.1.0"))
       implementation(npm("@cashapp/sqldelight-sqljs-worker", "2.1.0"))
       implementation(npm("sql.js", "1.8.0"))
    }
    }
    sqldelight {
       databases {
          create("Database") {
             packageName.set("ar.com.cancerbero")
             deriveSchemaFromMigrations.set(true)
             verifyMigrations.set(true)
             generateAsync.set(true)
          }
       }
    }
    the webpack.config.d/sqljs.js seems to be working...
    Copy code
    config.resolve = {
       fallback: {
          fs: false,
          path: false,
          crypto: false,
       }
    };
    
    const CopyWebpackPlugin = require('copy-webpack-plugin');
    config.plugins.push(
       new CopyWebpackPlugin({
          patterns: [
             '../../node_modules/sql.js/dist/sql-wasm.wasm'
          ]
       })
    );
    the provideDbDriver:
    Copy code
    private val workerScriptUrl: String = js("""new URL("@cashapp/sqldelight-sqljs-worker/sqljs.worker.js", import.meta.url)""")
    
    actual suspend fun provideDbDriver(
       schema: SqlSchema<QueryResult.AsyncValue<Unit>>
    ): SqlDriver {
       return WebWorkerDriver(
          Worker(workerScriptUrl)
       ).also { schema.create(it).await() }
    }
    The initialization logic:
    Copy code
    object StoreApp {
       val scope = CoroutineScope(Dispatchers.Default)
    
       private var database: Database? = null
    
       init {
          scope.launch {
             val driver = provideDbDriver(Database.Schema)
             database = createDatabase(driver)
          }
       }
    }
    This error appears at first moment, with no use... So LATER when i try to do something like: it crashes:
    Copy code
    db!!.key_valuesQueries.selectValue("selectedStoreId").asFlow().mapToOneOrNull(Dispatchers.Default),
    because of null pointer exception... The Database,kt in commonMain:
    Copy code
    expect suspend fun provideDbDriver(
       schema: SqlSchema<QueryResult.AsyncValue<Unit>>
    ): SqlDriver
    
    fun createDatabase(driver: SqlDriver): Database {
       return Database(driver)
    
       // Do more work with the database (see below).
    }
  • z

    Zoltan Demant

    11/07/2025, 6:29 AM
    It appears that
    id TEXT AS Id PRIMARY KEY
    is somehow null in my SqlDelight database for ~100 of my users. Then crashes at runtime due to:
    performanceSqlAdapter.idAdapter.decode(cursor.getString(0)!!)
    The id class is a string value class that makes sure the string is never null or empty. This works for 99,99% of the userbase; but 100 people is still a lot. Any clues?
    • 1
    • 1
  • c

    Cosmin Mihu

    11/10/2025, 4:30 PM
    Sqldelight WebDriver Error For the following code (wasm + js tagets):
    Copy code
    import app.cash.sqldelight.async.coroutines.awaitCreate
    import app.cash.sqldelight.db.SqlDriver
    import app.cash.sqldelight.driver.worker.WebWorkerDriver
    import app.cash.sqldelight.driver.worker.expected.Worker
    import kotlinx.coroutines.Dispatchers
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import kotlin.js.js
    
    internal actual fun createDatabaseDriver(): SqlDriver {
        return WebWorkerDriver(jsWorker()).also {
            GlobalScope.launch(Dispatchers.Default) {
                LibraryDatabase.Schema.awaitCreate(it)
            }
        }
    }
    
    private fun jsWorker(): Worker =
        js("""new Worker(new URL("@cashapp/sqldelight-sqljs-worker/sqljs.worker.js", import.meta.url))""")
    I have this error.
    Copy code
    e: DatabaseDriverFactory.kt:22:25 Cannot access 'typealias Worker = Worker': it is internal in file.
    Is something that I miss?
  • e

    eygraber

    11/11/2025, 7:55 PM
    Out of nothing other than curiosity, is there anything publicly shareable about the state of open source at Cash App? I know there was a message on SqlDelight about how functionality not related to use at Cash App won't be focused on, but it seems like it's more than just SqlDelight: • Paparazzi • Redwood being EOL
    j
    g
    +2
    • 5
    • 16
  • y

    Yassine Abou

    11/14/2025, 11:17 PM
    SQLDelight 2.2.1 doesn't work with WebAssembly yet. I'm getting web worker errors, and I see there are GitHub issues open about it. Here are the GitHub issues: • #5930: https://github.com/sqldelight/sqldelight/issues/5930 • #5874: https://github.com/sqldelight/sqldelight/issues/5874 • #5849: https://github.com/sqldelight/sqldelight/issues/5849 • #5848: https://github.com/sqldelight/sqldelight/issues/5848 Do you know when this will be fixed?
    j
    h
    g
    • 4
    • 6
  • c

    crowforkotlin

    11/17/2025, 11:13 AM
    I referenced the method provided by @jessewilson and used wazero to build a WebAssembly (WASM) process from Go to Kotlin, which executed successfully. The next steps include debugging Kotlin/WASM and implementing a WebAssembly bridge, which may later be integrated into the forked zipline project to facilitate the transition from Kotlin/JS to Kotlin/WASM. Thanks for providing the ideas. https://github.com/crowforkotlin/wazero-bride-jvm
    yes black 1
    j
    m
    • 3
    • 10
  • n

    Neil Miller

    11/17/2025, 7:45 PM
    I have some time to look into https://github.com/sqldelight/sqldelight/issues/4505 and https://github.com/sqldelight/sqldelight/issues/4922 that are causing us some issues. I'm familiar with the overall project structure for SQLDelight, but if anyone has any pointers on where to look, that would be much appreciated! In particular for the first issue, it's not clear to me if that is an issue in
    app.cash.sql-psi
    or SQLDelight. Thanks!
    • 1
    • 1
  • h

    Hrodrick

    11/18/2025, 4:56 PM
    Quick question, on the SQL delight docs for KMP it says the sql files should be at
    src/main/sqldelight
    but I've never seen any KMP project with a
    src/main
    folder. All the projects I work with use a
    src/commonMain
    module. Do I still need to have the sqls on a main src folder or is it possible to have them on commonMain?
    h
    s
    • 3
    • 3