https://kotlinlang.org logo
Join SlackCommunities
Powered by
# squarelibraries
  • m

    Mark

    02/23/2025, 5:43 AM
    I’m trying to set up an
    UPDATE
    that returns the original values being replaced. It seems
    RETURNING
    is the way to go but sqldelight won’t allow the
    WITH
    table columns to be referenced like this. Is this a limitation of sqldelight or have I got the syntax wrong?
    Copy code
    WITH old_values AS (
        SELECT id, date FROM history
        WHERE date NOT GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
    )
    UPDATE history
    SET date = '1970-01-01'
    WHERE id IN (SELECT id FROM old_values)
    RETURNING old_values.date; // compilation error
  • a

    alireza_rmz

    02/23/2025, 1:29 PM
    How is caching managed in projects that use Redwood? Does Redwood provide any built-in caching mechanisms, or are there recommended best practices for optimizing caching?
    j
    • 2
    • 2
  • d

    Drake Gebhart

    02/25/2025, 1:57 AM
    Heyo! I'm looking to write a simple app log file using Okio on Kotlin Multiplatform for iOS/Android. This will literally just be a text file and I'm just writing strings to it. I added Okio to my KMP project and in my commonMain I wrote the example provided:
    Copy code
    val path = "applog.txt".toPath()       
            FileSystem.SYSTEM.appendingSink(path).buffer().use { sink ->
                sink.writeUtf8(message)
            }
    I get an error on both iOS and Android
    Copy code
    Caused by: java.io.FileNotFoundException: applog.txt: open failed: EROFS (Read-only file system)
    	at libcore.io.IoBridge.open(IoBridge.java:492)
    	at java.io.FileOutputStream.<init>(FileOutputStream.java:236)
    	at okio.Okio__JvmOkioKt.sink(JvmOkio.kt:173)
    Looking around it looks like Okio w/ KMP works in common now but I'm not seeing many examples?
    ✅ 1
    j
    • 2
    • 7
  • r

    Rohan Maity

    02/25/2025, 7:10 PM
    🧵 Okhttp not adding WebSocket headers like automatically. Is this expected?
    Copy code
    "Connection" to "Upgrade",
                "Sec-WebSocket-Extensions" to "permessage-deflate",
                "Upgrade" to "websocket",
                "Sec-WebSocket-Version" to "13",
                "Sec-WebSocket-Key" to secWebSocketKeyValue
    j
    j
    • 3
    • 14
  • u

    ursus

    03/03/2025, 3:25 PM
    Copy code
    @SingleInstance(AppScope::class) <--------
    @ContributesBinding(AppScope::class) <--------
    class DocsRepositoryImpl @Inject constructor(
    	...
    ) : DocsRepository
    I'd assume most
    anvil
    users have something like this Is there a way to do away with the
    AppScope::class
    literal duplication?
  • l

    Lukasz Kalnik

    03/05/2025, 9:38 AM
    We're using OkHttp (through Ktor) and getting on one of our servers an UnknownHostException caused by
    android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
    . However the same URL opens without problems on the same mobile device in Chrome browser. Also it's independent if I'm in the mobile network or WiFi. Also running
    adb shell ping
    on this URL gets an unknown host.
    d
    j
    y
    • 4
    • 10
  • u

    ursus

    03/06/2025, 8:03 PM
    Copy code
    java.util.ConcurrentModificationException
            at java.base/java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:756)
            at java.base/java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:778)
            at java.base/java.util.AbstractCollection.addAll(AbstractCollection.java:335)
            at app.cash.sqldelight.BaseTransacterImpl.postTransactionCleanup(Transacter.kt:289)
            at app.cash.sqldelight.TransacterImpl.transactionWithWrapper(Transacter.kt:376)
            at app.cash.sqldelight.TransacterImpl.transaction(Transacter.kt:349)
            at app.cash.sqldelight.Transacter$DefaultImpls.transaction$default(Transacter.kt:94)
            at ...my code
    I'm lately seeing this in tests (when driving the db with jdbc) anyone seen this before? rerunning makes it go away -_-
  • k

    Kim

    03/10/2025, 2:55 AM
    I noticed a new kotlin-formatter project released just this year, which seems to be a wrapper around ktfmt. I cannot find any blogposts or such regarding this, what is the motivation for this new project i.e. what issues does this project address that the current ktfmt CLI/IDE plugin cannot?
    👀 1
    k
    m
    s
    • 4
    • 5
  • m

    Mark

    03/18/2025, 9:52 AM
    According to
    SqlDriver.execute
    documentation, non insert/delete/update SQL return 0, but when I use
    VACUUM INTO
    I get 1 (mostly, though 0 sometimes which I presume is when nothing changed). Is this expected?
    d
    • 2
    • 1
  • c

    Christopher Mederos

    03/19/2025, 1:06 AM
    Anyone link sqlite properly in a CMP project recently? https://kotlinlang.slack.com/archives/C0346LWVBJ4/p1742346161750919
  • a

    Aleksandar Ilic

    03/20/2025, 12:38 PM
    Hey square devs, I need some help/feedback for
    cash-app-paging-runtime-ui-kit
    . Got stuck with something for a while. I have a KMP shared library which gets exported as XCFramework so that native iOS app can use the data layer which exposes
    Flow<androidx.paging.PagingData<T>>
    . When I added `api("app.cash.paging:paging-runtime-uikit")`to
    iosMain
    in shared library, for native iOS project to get
    PagingCollectionViewController
    , I started getting following error when
    assembleXCFramework
    starts. The error is:
    Copy code
    * Source files: 
     * Compiler version: 2.1.10
     * Output kind: FRAMEWORK
    
    e: java.lang.IllegalStateException: IrClassSymbolImpl is unbound. Signature: androidx.paging/NullPaddedList|null[0]
            at org.jetbrains.kotlin.ir.symbols.impl.IrSymbolBase.getOwner(IrSymbolImpl.kt)
    Both paging libraries (androidx and cashapp) are at
    3.3.0-alpha02
    . Anyone have any idea what is wrong here? Any hint is appreciated. Thanks!
  • s

    Seth Madison

    03/21/2025, 4:09 AM
    @jw I see that you added the response-type-keeper plugin to Retrofit last year. Is there a reason that it is limited to just the response types, and doesn’t also
    keep
    the types of the method arguments? We have a situation where we pass serialized data in the
    @Body
    of a request, and the plugin won’t automatically keep those types. I guess if it did, we’d need a different name for the plugin, since it would be keeping request AND response types.
    j
    • 2
    • 1
  • d

    David B

    03/21/2025, 8:57 AM
    Hi SQLDelight team. Postgres types
    timestamp
    and
    timestampz
    aren’t currently modelled in SQLDelight as
    java.time.Instant
    value in Java / Kotlin. They’re modelled as
    LocalDateTime
    and
    OffsetDateTime
    instead: https://sqldelight.github.io/sqldelight/2.0.2/jvm_postgresql/types/ The naming of these column types in Postgres is somewhat confusing. The “with timezone” makes it sound like it’s storing some timezone data in your column. It isn’t. The “with timezone” only affects how a String is converted to and from a Timestamp when you’re using a SQL Client. You’re telling Postgres “I want you to interpret my string in the context of the Postgres server’s timezone” or “I want you to display these timestamps with respect to whatever timezone I’ve set in the Postgres server”. These String-based concerns have no relevance when you’re reading and writing a value from a Java object that’s backed by an unambiguous Long milliseconds-since-Epoch UTC value. Anyway, to cut a long story short, I think that the choice of
    Instant
    is the most appropriate way of reading and writing these timestamp (milliseconds since Epoch) values. I’d be interested to hear your thoughts, and whether this discussion has already been held. Thanks.
    g
    • 2
    • 3
  • u

    ursus

    03/22/2025, 8:03 PM
    Is trying to use
    sqldelight
    in ktor server a bad idea? I'm already familiar with it but I'm unsure about the schema creation, ddl etc, since sqldelight seems to be driven by the DDL - which from what I gather is not used in backend apps? (I'm a android developer, backend noob)
    j
    • 2
    • 25
  • n

    Nikky

    03/24/2025, 10:30 PM
    sqldelight question: is there any way for me to run something using system columns?
    Copy code
    RETURNING (xmax = 0) AS inserted
    is a trick to determine if a row got inserted or updated (and i hope it still works) but sqldelight does not know what
    xmax
    is anyone got ideas on this ? from: https://stackoverflow.com/questions/39058213/differentiate-inserted-and-updated-rows-in-upsert-using-system-columns
    g
    • 2
    • 2
  • a

    alexhelder

    03/26/2025, 9:41 PM
    firebase network performance monitoring supports okhttp3 out of the box. Anyone here know what needs to be done to make it work with okhttp4?
    j
    • 2
    • 4
  • a

    Agustín Ponce

    04/01/2025, 8:11 AM
    Hello! Does anyone know if SQLDelight is usable in WasmJs today?
    f
    a
    • 3
    • 2
  • z

    Zoltan Demant

    04/03/2025, 9:25 AM
    It seems that most paging libraries let you invalidate the dataset from the outside, i.e. pager.invalidate. Could anyone explain why thats the default in paging, compared to loading a
    Flow<List<T>>
    for each of its pages, that then gets combined into the final
    Flow<List<T>>
    with all the items?
    j
    • 2
    • 1
  • c

    Colton Idle

    04/10/2025, 6:39 PM
    I have to bake in a 15MB csv into my new app and then immediately on launch start inputting it into my sqldelight db. Can I just skip that middle step and ship a db/table with my android app?
    👌 5
    j
    e
    m
    • 4
    • 15
  • u

    uli

    04/14/2025, 3:10 PM
    Hi all, I am toying around with sqldelight in a KMP project to evaluate for future use. I am currently trying to understand how database creation is meant to work and can not find a lot about it in the docs. For Jvm with the app.cash.sqldelight:sqlite-driver driver, I had SQLDelight complain, that the database file does not exist at first run. So I added code to check if the db file exists and call Schema.create(driver). On native, I realized, that I can not give a path to the driver, but just a name. Then I had to reverse engineer the full path to check if the DB already exists … This is not what I expect from a square library, so I must have missed something here?
    h
    • 2
    • 6
  • r

    Ryan Woodcock

    04/17/2025, 1:29 AM
    Hi all, is SQLDelight going to get a new stable release anytime soon? The lack of K2 support with the released plug in version now that k2 is standard is an issue for our workflow
    j
    l
    j
    • 4
    • 13
  • r

    Rohan Maity

    04/17/2025, 2:07 PM
    🧵 How can I add import for
    "kotlinx.coroutines.flow.mapNotNull"
    using kotlin poet? I tried the below it does not add import for the extension function
    Copy code
    FileSpec.builder(packageName, factoryClassName)
                    .addImport("kotlinx.coroutines.flow", "mapNotNull")
    h
    c
    • 3
    • 13
  • a

    Adam S

    04/19/2025, 9:56 AM
    SQLDelight docs question:
    id INT AS VALUE
    shows an error for me, "<type name real> expected, got 'INT'". Should it be
    id INTEGER AS VALUE
    ? https://sqldelight.github.io/sqldelight/2.0.2/jvm_sqlite/types/#value-types
    h
    • 2
    • 1
  • n

    Nabeel

    04/24/2025, 6:19 PM
    Hi, After updating to Kotlin 2.1.0, Moshi throwing exception on reflection related issues for types like LocalDate, LocalTime, LocalDateTime (I think classes under java.time). For every other custom types everything is working fine. And also with Kotlin 2.0.0 Exception in 🧵
    j
    • 2
    • 14
  • p

    Pearce Keesling

    04/30/2025, 4:50 PM
    We are using molecule and in bugsnag I've been seeing an intermittent failed trySend inside of
    immediateClockFlow
    . Makes me think that I am somehow emitting twice before the output buffer is able to receive a value. Any tips on how I should hunt that down? Stack trace in 🧵
    • 1
    • 1
  • a

    alp

    05/01/2025, 10:15 PM
    Hi all, while using coil with to load images with
    Cache-Control
    response headers, I noticed that if memory cache is enabled and there is an image in the cache for the requested key, then the cache control header is not respected because cached value is returned before
    CacheControlCacheStrategy
    is queried. Is it an expected behavior or there is a way to configure coil to respect cache control with the memory cache enabled?
    j
    c
    • 3
    • 6
  • c

    Colton Idle

    05/02/2025, 12:57 AM
    I'm trying to remember some conference talk from long long ago (maybe droidcon montreal) and I'm fairly certain there was some talk regarding a square library that was used to persist transactions before they could actually be sent over the wire (i.e. like if a payment reader was taking a payment while a device is online. so it had to be save). i also think that was the first time i learned of the word "idempotency". anyway. if that rings a bell for any of you square folks... plz let me know!
    j
    • 2
    • 20
  • t

    Tolriq

    05/04/2025, 7:37 PM
    Just got an ANR reported caused by Coil that by default will use okio FileSystem that use reflection to detect nio. Seems everything is internal but since I'm API 28+ on that app I can probably skip that part and directly provide the nio version of the filesystem. Is there anything obvious I'm missing to do that without duplicating the code ?
  • m

    Mateu

    05/05/2025, 3:17 PM
    I'm trying to use Sqldelight in a native project. To start with its a x86_64-linux. When I run the app I get the following error:
    Copy code
    .konan/dependencies/llvm-16.0.0-x86_64-linux-essentials-80/bin/ld.lld command returned non-zero exit code: 1.
    output:
    ld.lld: error: unable to find library -lsqlite3
    
    FAILURE: Build failed with an exception.
    Should something be configured? In iOS projects I add the linkerOpts.add("-lsqlite3"), but don't know how to do this in a linux native project. Thanks
    k
    • 2
    • 2
  • r

    Rohan Maity

    05/05/2025, 3:47 PM
    QQ: Does the okhttp websocket re-send the message if the message does not reach the server in case of Flaky network?
    j
    • 2
    • 5