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

    Zoltan Demant

    05/26/2025, 9:50 AM
    When I use 'active' below, I get Query<SessionSql>; but when I use 'recent' I get Query<Recent> even though both queries include the same exact fields. If I comment out
    WHERE endTime IS NOT NULL
    I get identical behavior between the two.
    Copy code
    active:
    SELECT *
    FROM sessionSql
    WHERE endTime IS NULL
    ORDER BY startTime;
    
    recent:
    SELECT *
    FROM sessionSql
    WHERE endTime IS NOT NULL
    ORDER BY endTime DESC
    LIMIT :count;
    h
    • 2
    • 3
  • c

    Cies

    05/27/2025, 12:15 AM
    is it true I cannot do
    SET ROLE anon;
    on Postgres, through SQLDelight?
    e
    • 2
    • 22
  • m

    maylo0852

    05/27/2025, 1:33 PM
    Hi all, Is there a way how I can replace dependencies with Anvil using
    replaces
    in a separate android test module (apply com.android.test) ?
    Copy code
    @Module
    @ContributesTo(
        scope = AppScope::class,
        replaces = [ActualModule::class],
    )
    object TestActualModule {
    
        @Provides
        @SingleIn(AppScope::class)
        fun providesTestImpl(): TestImpl = TestImpl()
    }
    Anvil correctly generates Factory class for this, but it's not contributed in the
    DaggerAppComponent
    j
    • 2
    • 2
  • c

    Cies

    05/28/2025, 8:57 AM
    I'm evaluating SQLDelight, and there is a lot for me to love about it. 1) type safe, generated, functions for me to call in my code, that link to my SQL statements. 2) SQL checking at build time. But there's also a lot that makes it hard for me to use this in practice: it seems that only a subset of PG syntax is supported. And --as I now understand it-- I cannot pick only part of the deal (I'd want it to not do SQL checks, just the generated kotlin interfaces to my SQL statements as it does so much better than jdbi-kotlin) with SQLDelight: it's all or nothing. But maybe I'm wrong...
    p
    a
    +2
    • 5
    • 15
  • b

    bod

    05/28/2025, 2:35 PM
    Hey when using SQLDelight with JS/Wasm + SQL.js, everything is in-memory only by default, right? Is there a recipe to keep things persisted? I've seen mentions of "IndexedDb" and "OPFS" here and there, but nothing concrete. Is it a thing?
    ➕ 2
    👀 1
    e
    • 2
    • 5
  • s

    Shubham Singh

    06/01/2025, 3:20 PM
    Greetings of the day friends Has anyone tried creating a Google Chrome Extension using Kotlin Multiplatform with SQLDelight/JS? After adding SQLDelight as a dependency to the extension, I see this error. Seems like Chrome extensions can't run JS or WASM scripts because of some CSP restriction.
    b
    • 2
    • 1
  • z

    Zoltan Demant

    06/02/2025, 11:00 AM
    Is there any simple way to remove a NOT NULL contraint from a table in SqlDelight? Seems that I need to copy the table into a temporary one, then back after updating the table?
    b
    • 2
    • 4
  • y

    Yassine Abou

    06/03/2025, 12:46 AM
    When running my Kotlin/Wasm target in the browser, I encounter Webpack errors (the application works correctly on Android, desktop, and iOS targets). Below is my SQLDelight Wasm Gradle configuration and the error details: wasmJsMain.dependencies {
    Copy code
    implementation(libs.sqldelight.web.driver)
        implementation(npm("sql.js", libs.versions.sqlJs.get()))
        implementation(npm("@cashapp/sqldelight-sqljs-worker", "2.1.0"))
        implementation(devNpm("copy-webpack-plugin", libs.versions.webPackPlugin.get()))
    }
    👀 1
    b
    • 2
    • 1
  • b

    Bas de Groot

    06/03/2025, 6:45 AM
    Hi, We want to use SQLDelight and have a use case where our queries use environment-specific table name prefixes. For example,
    $someEnv
    or
    $someOtherEnv
    , as shown below:
    Copy code
    SELECT
        ...
    FROM
        $someEnv.some_table td ON td.transaction_dossier_id = cs.transaction_dossier_id
            JOIN
        $someOtherEnv.some_other_table mc_go ON rv.grid_operator = mc_go.mtc_ean
    How can we best support this behavior in SQLDelight? Is there a way to dynamically parameterize or pass these prefixes at runtime? Any guidance or workarounds would be greatly appreciated.
  • u

    ursus

    06/03/2025, 6:42 PM
    Hi, are there maybe updates on anvil's K2 support?
    ➕ 2
    g
    m
    +2
    • 5
    • 34
  • y

    Yassine Abou

    06/05/2025, 3:51 AM
    When generating a Compose Desktop release build and opening the app, I encounter a j*ava/sql/DriverManager* error. how could I fix it?
    s
    • 2
    • 2
  • s

    Slackbot

    06/06/2025, 3:40 AM
    This message was deleted.
    👀 1
    y
    • 2
    • 1
  • j

    jrod

    06/10/2025, 8:17 PM
    from my understanding, SqlDelight currently runs
    verifyMigrations
    only on
    check
    runs, but if I run
    assemble
    or
    install
    (assume an Android project), then verify won't run. 1. is that right? 2. if so, is the solution to explicitly Gradle-wire the task to `assemble`/`install`? 3. if so, got a lazyweb snippet handy? the AGP variant.assembleProvider way seems to no longer be available in later versions.
    j
    • 2
    • 3
  • y

    Yassine Abou

    06/11/2025, 12:27 AM
    I'm encountering an error while setting up SQLDelight for WebAssembly in a Kotlin Multiplatform project targeting WebAssembly. When initializing the database worker, I get the following console error:
    Copy code
    composeApp.uninstantiated.mjs:189 WebWorkerException:
      {
        "message":"Uncaught SyntaxError: Unexpected token '<'",
        "type":"error"
      } isTrusted,true
      kotlinx.coroutines.error_$external_fun @ composeApp.uninstantiated.mjs:189
    Is this primarily a SQLDelight configuration issue or a coroutines uncaught exception? Relevant Code Snippets: Database Configuration:
    Copy code
    private val workerScriptUrl: String = 
          js("""new URL("@cashapp/sqldelight-sqljs-worker/sqljs.worker.js", import.meta.url)""")
      
      actual val platformModule = module {
          single {
              val driver = WebWorkerDriver(Worker(workerScriptUrl)).apply {
                  enableForeignKeys()
              }
              LlmsDatabaseWrapper(driver, LlmsDatabase(driver))
          }
      }
    Webpack Configuration (sqljs.js)
    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'
              ]
          })
      );
    for more context. check out this repository link: https://github.com/yassineAbou/LLMS
  • b

    bod

    06/11/2025, 9:41 AM
    Something unclear to me when using SQLDelight with
    generateAsync.set(true)
    . Any call to
    driver.executeQuery()
    should be migrated to
    driver.awaitQuery()
    , right? But this doesn't seem to work with a non-async driver such as the JDBC one on the JVM. For instance I'm doing this:
    Copy code
    driver.awaitQuery(
      null,
      "PRAGMA $versionPragma",
      { cursor ->
        // The cursor is already closed here
        if (cursor.next().await()) {
          cursor.getLong(0)
        } else {
          null
        }
      },
      0
    )
    using the debugger I can see that my lambda is called after the statement has already been closed which obviously cannot work. I must be missing something obvious? 🤔 Other extensions like
    awaitAsOneOrNull()
    seem to work as expected.
    j
    • 2
    • 3
  • m

    Michael Paus

    06/12/2025, 9:54 AM
    I am having problems with SQLDelight and SQLite on desktop. I have tested all my queries via the SQLite Browser before I started to migrate a project to use SQLDelight/SQLite. Now it turns out that even the latest version of SQLDelight (2.1.0) only supports an ancient dialect of SQLite (3.18?) which has lots of limitations compared to modern SQLite. Is there any way to configure a more recent dialect version or any other workaround for this?
    g
    e
    s
    • 4
    • 7
  • e

    Eric Ampire [MOD]

    06/15/2025, 5:50 PM
    Hello, I’ve spend lot of time trying to understand why SQLDelight was always returning null for a specific field even though the value wasn’t null in the database until I’ve decided to put the properties of my data class in the same order as they are declared in the .sq TABLE, Is it normal to have that behaviour ?
    h
    • 2
    • 1
  • k

    Karan Sharma

    06/16/2025, 11:36 AM
    [SQLDelight - ios only] Is it possible to ensure migrations are run before I try to access the DB? Use case: On app start in home screen, need to read data from db and display it. Seems like db is not migrated to next version and table is not yet created but I try to access it. 😞 Not sure how to ensure migrations are run before I access db? PS - Android seems to be okay ios is having issues. Logs in 🧵
    ios crash log
    e
    • 2
    • 7
  • b

    Brian Gardner

    06/16/2025, 5:44 PM
    Hey folks! Our team just released a new open source library called Trailblaze which allows writing end to end tests using natural language which are driven by an AI agent. It is still under active development and we’re having good success with both the Square point of sale app and CashApp! AI-driven testing is gaining a lot of momentum across various disciplines and we look forward to iterating and collaborating on a solid solution for mobile clients
    🎉 3
  • a

    Agustín Ponce

    06/18/2025, 5:05 PM
    Hi, I was messing around with SQLDelight and WASM without much success before version 2.1.0 came out. Now that it's supported in the current release, I'd like to pick it up again, but I'm not sure if there's any official documentation or example repo available. Right now, I'm a bit lost because of all the experiments I did before this version.
    y
    b
    • 3
    • 7
  • a

    Alex

    06/23/2025, 1:29 PM
    Hi all! I'm working on upgrading our Android project's SQLDelight version from 2.0.1 to 2.10, but seeing an issue compiling after upgrading where it does not recognize
    last_insert_rowid()
    Copy code
    Unknown function last_insert_rowid
        SELECT last_insert_rowid()
               ^^^^^^^^^^^^^^^^^^^
    last_insert_rowid()
    is a part of SQLite, is there some kind of change made to override this in the latest update? I was unable to find anything directly referencing it in the changelogs
    ➕ 1
    j
    • 2
    • 1
  • u

    ursus

    06/25/2025, 1:33 PM
    Does anvil not work with kotlin 2.2.0 for anyone else as well?
    👌 1
    s
    • 2
    • 1
  • r

    Ryan Woodcock

    06/27/2025, 4:51 AM
    Is there any chance this issue with the sqldelight plugin will be looked at any time soon? Currently the plugin is constantly flashing and not providing syntax highlighting in intellij https://github.com/sqldelight/sqldelight/issues/5664
    ➕ 3
  • c

    Colton Idle

    06/29/2025, 2:38 PM
    This post by Dan Abramov https://overreacted.io/progressive-json/ is making me rethink how json is parsed/deserialized via okhttp. From what Dan says you can't deserialize json until its completely downloaded, but i always thought with okhttp + moshi (or whatever) that the deserialization happens while streaming the resopnse. i vaugley remember a droidcon talk where jake/jesse talked about amoritized cost of network response vs deserialization. and even the fact that json serializer benchmarks that use strings aren't really benchmarking the right thing. Can someone confirm if okhttp allows streaming of responses + streamed deserialization?
    j
    m
    j
    • 4
    • 14
  • j

    jessewilson

    06/29/2025, 5:06 PM
    I’m preparing OkHttp 5.0.0 and I’m looking for some community help. Can you please try out
    5.0.0-alpha.17
    in your projects and let me know if you run into any surprises? OkHttp 5.x introduces separate
    -jvm
    and
    -android
    artifacts. We’ve had reports (issue 8826) that some builds incorrectly classes from both a
    okhttp-android
    5.x artifact and a
    okhttp
    4.x artifact, which causes crashes at runtime. I haven’t been able to reproduce this. If you can repro this, please reply on thread; I’d love to get to the bottom of this. My intention is for 5.x to have zero backwards-incompatible changes with 4.12. If you see any, again please let me know.
    e
    t
    +2
    • 5
    • 17
  • z

    Zoltan Demant

    07/04/2025, 4:17 AM
    Im looking into a potential race condition with SqlDelight:
    Copy code
    private val database by lazy {
        scope.async { init() }
    }
    
    suspend fun database() = database.await()
    The
    suspend fun init()
    function creates the actual database and makes sure some template data is inserted the first time around. The whole point is that this happens before other areas of my app can touch the database. Ive been doing this for years and it has worked brilliantly, but recently something seems to have changed: under some scenario, the database is accessed before the template data is inserted. Ill add some more details in 🧵 in order to keep this somewhat short.
    e
    • 2
    • 41
  • v

    Vivek Modi

    07/09/2025, 10:41 PM
    Hey guys, I'm using the square wire client library on the kmm + cmp project. When I use the wire client library in the commonMain it gives me an error on wasmJs. Could any one can help with this?
    j
    b
    • 3
    • 8
  • m

    Mark

    07/10/2025, 6:58 AM
    In sqldelight, when making raw queries, how to ensure identifiers do not conflict with generated query identifiers? Is there a range etc?
    h
    • 2
    • 4
  • a

    Adam S

    07/10/2025, 7:28 AM
    SQLDelight question: is there a docs page that lists all of the valid built-in data types, and what Kotlin type they correspond to? E.g. TEXT = String
    • 1
    • 1
  • a

    Adam S

    07/11/2025, 10:20 AM
    SQLDelight question: The docs explain how to enable foreign keys for SQLite, but how are they actually defined in a
    .sq
    file? https://sqldelight.github.io/sqldelight/2.1.0/jvm_sqlite/foreign_keys/
    e
    • 2
    • 1