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

    Colton Idle

    08/11/2025, 2:51 PM
    Maybe a dumb question. But im working on a library (regretfully 😂) and we need to make network calls. would love to use okhttp + kotlinx.serialization, but we don't want to go all in and pull in retrofit. Is there an "easy" way to deserialization with okhttp without brining in retrofit?
    m
    j
    • 3
    • 8
  • c

    Colton Idle

    08/11/2025, 3:12 PM
    Another fun one... This is weird right? We have a slim network layer (on top of okhttp) to just make a few things a bit easier. and we have a
    Copy code
    fun sendSync(req: Req): Res
    return runBlocking {
      sendAsync()
    }
    Copy code
    suspend fun sendAsync() {...}
    k
    g
    • 3
    • 16
  • u

    ursus

    08/11/2025, 3:25 PM
    With okhttp 5.1 my minified android build fails with
    Copy code
    > Task :foo:app:minifyTstStableReleaseWithR8 FAILED
    ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/bar/AndroidStudioProjects/foo/app/build/outputs/mapping/tstStableRelease/missing_rules.txt.
    ERROR: R8: Missing class okhttp3.internal.Util (referenced from: void okhttp3.internal.sse.RealEventSource.processResponse(okhttp3.Response) and 1 other context)
    Anyone else experiencing this?
    c
    y
    • 3
    • 29
  • d

    Deep Patel

    08/16/2025, 4:19 AM
    Does anyone know if the workflow kt test library supports pure kotlin or multiplatform? I have an app built in multiplatform using workflow kt but can’t test it since last I checked the test library was only supported for the jvm target
    z
    b
    • 3
    • 20
  • c

    Colton Idle

    08/21/2025, 1:44 PM
    Trying to understand which parts of okhttp are "value classes" Struggling with whether or not https://square.github.io/okhttp/3.x/okhttp/okhttp3/Request.html is a value class because of it's description
    An HTTP request. Instances of this class are immutable if their body is null or itself immutable.
    Like if this was written in kotlin would it just be a data class?
    m
    j
    y
    • 4
    • 16
  • u

    ursus

    08/22/2025, 1:04 PM
    If
    turbine
    gurus could chime in
    Copy code
    private val _state = MutableStateFlow<ChatState>(ChatState.Idle)
    override val state: Flow<ChatState> get() = _state
    
    scope.launch {
        combine(
            conversationDao.conversation.doOnNext { println("-- CONVERSATION=$it") },
            connector.connectionState.doOnNext { println("-- CONN_STATE=$it") },
            ::stateMapper
        )
            .collect {
                println("--- PRODUCED=$it")
                _state.value = it
            }
    }
    I have
    combine
    which produces as a result and pipes it into stateflow
    _state
    . That
    state
    flow is then asserted at test time with turbine (ommited) Issue is that for some reason this is not deterministic. Default value of
    connectionState
    is
    Disconnected
    and then obviously
    Connecting etc
    What I'm seeing is that sometimes I see
    Connecting
    getting emitted before the product of combining with
    Disconnected
    gets set to the
    _state
    Othertimes it's not and I see 2 `--- PRODUCED`as expected. Is this a
    StateFlow
    issue? A
    combine
    issue? A Turbine issue? A
    TestDispatcher
    issue? Should I maybe not assert all the intermediary emits and just the last one using?
    c
    • 2
    • 6
  • a

    Alexander Ioffe

    08/29/2025, 8:55 PM
    Question for SqlDelight maintainers. Would you be willing to take a PR to either: 1. Expose
    sqliter.Cursor
    from SqliterSqlCursor,
    ResultSet
    from JdbcCursor, etc... or 2. Expose some kind of
    CursorMetadata
    API? I'm trying to see if I can integrate my libraries Terpal/ExoQuery with SQLDelight and the missing piece seems to be DB result-set metadata.
  • 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).
    }