https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
squarelibraries
  • s

    Slackbot

    06/13/2022, 1:03 PM
    This message was deleted.
    j
    • 2
    • 2
  • m

    Michal Klimczak

    06/14/2022, 9:47 AM
    I'm getting
    java.lang.IllegalStateException: Unsupported type BookDto at com.squareup.kotlinpoet.metadata.classinspectors.JvmDescriptorTypeVisitor.visitUnknown(JvmDescriptorUtils.kt:191)
    . BookDto is a simple data class generated by sqldelight. Then during kapt phase my processor tries to generate a few classes and without
    correctErrorTypes = false
    it generates them with
    NonExistentClass
    and with
    correctErrorTypes = true
    this error. What could that mean? The line that causes it in the processor:
    val typeSpec = (element as TypeElement).toTypeSpec(classInspector)
    Also it's random. From time to time it builds just fine, but 80% of the time it fails. (kotlinpoet 1.10 and 1.11, kotlin 1.6.21, sqldelight 1.5.3, full exception in thread)
    z
    • 2
    • 6
  • j

    jw

    06/17/2022, 11:39 AM
    You have to change all the groupIds to app.cash instead of com.squareup
    👍 1
    s
    d
    • 3
    • 2
  • a

    alec

    06/17/2022, 4:35 PM
    ~20min for stuff to propagate through maven
    🕐 1
    b
    • 2
    • 1
  • j

    jw

    06/18/2022, 8:37 PM
    That's pretty standard for InputStream, at least
    j
    • 2
    • 19
  • a

    Aidan Low

    06/21/2022, 8:56 PM
    How can I best use turbine to verify the eventual value of a StateFlow? If I use
    awaitItem()
    I seem to see each individual time the StateFlow was set, but what I care about is the eventual value after a number of operations. It manifests most painfully in my combine-heavy view model with a lot of
    .stateIn()
    operations but can also be seen in
    val stateFlow = MutableStateFlow(false)
    stateFlow.test {
      stateFlow.value = true
      val a = awaitItem() // this is false
      val b = awaitItem() // this is true
    }
    t
    e
    • 3
    • 6
  • j

    jw

    06/21/2022, 9:00 PM
    Consider asserting on value rather than using Turbine
  • a

    Aidan Low

    06/21/2022, 9:04 PM
    The state flows in question were created via
    .stateIn(
        scope = viewModelScope,
        started = SharingStarted.WhileSubscribed(),
        initialValue = emptyList()
    )
    and I was hoping to use turbine to manage subscription to the flows so that they would update properly. Is there a recommended pattern to do that so that I can assert on the value despite the subscription requirement?
  • j

    jw

    06/21/2022, 9:06 PM
    Well, it's kinda weird but you can still call .test and then cancel at the end. Otherwise launch a coroutine with an empty collect and then cancel the job at the end of the test
  • a

    Aidan Low

    06/21/2022, 9:07 PM
    I thought about that, but hoped there might be a cleaner way. I'll give that a shot, thanks.
  • a

    Aidan Low

    06/22/2022, 12:00 AM
    A helper like this seems to do the trick, though perhaps it's overly specific to my use case. Feedback is welcome.
    fun TestScope.observeStateFlows(
        vararg stateFlows: StateFlow<Any?>,
        block: () -> Unit
    ) {
        val observationJobs = stateFlows.map { flow ->
            launch {
                flow.collect {}
            }
        }
    
        try {
            runCurrent()
            block.invoke()
        } finally {
            observationJobs.forEach { it.cancel() }
        }
    }
  • e

    ephemient

    06/22/2022, 4:45 AM
    coroutineScope {
        for (flow in flows) flow.launchIn(this)
        coroutineContext.cancelChildren()
    :thank-you: 1
    🙌 1
  • j

    Javier

    06/23/2022, 12:47 PM
    Is on the roadmap of paparazzi to support Compose Multiplatform?
  • j

    jw

    06/23/2022, 12:49 PM
    You can file an issue. On desktop it should be pretty easy to capture screenshots since your code runs natively on the JVM already.
  • j

    Javier

    06/23/2022, 12:58 PM
    That means currently paparazzi doesn't need an Android module to run? Or that the integration should be easy?
  • j

    Javier

    06/23/2022, 12:59 PM
    Filed https://github.com/cashapp/paparazzi/issues/467
  • j

    jw

    06/23/2022, 1:00 PM
    An Android library module is currently required
    👍 1
  • j

    Javier

    06/23/2022, 1:10 PM
    Wops, currently it needs to be an android library and I has only KMP modules and app previews (android apps modules) 🙃
  • j

    jw

    06/23/2022, 1:14 PM
    KMP modules has an open PR here: https://github.com/cashapp/paparazzi/pull/450
    🔝 1
    👀 1
  • k

    krzysztof

    06/23/2022, 1:16 PM
    Hey, Using sqldelight, I’m trying to create a query that would insert variant number of key-value pairs into the table:
    CREATE TABLE IF NOT EXISTS example_table(
        key TEXT NOT NULL UNIQUE PRIMARY KEY,
        value TEXT
    );
    In sql, you can do something like
    INSERT INTO example_table (key, value)
    VALUES ("k1", "v1"), ("k2", "v2")
    How can I create such query, so that I can pass a list of my
    key-value
    entries? Such as
    db.insertMany(listOf(Entry(k1, v1), Entry(k2, v2)))
    ?
    ✅ 1
    a
    • 2
    • 4
  • b

    brabo-hi

    06/23/2022, 8:55 PM
    hi all, how can we
    insert
    or
    update
    if exist ?
    b
    • 2
    • 3
  • d

    Daniel Bucher

    06/24/2022, 10:37 AM
    Hello everyone, I’m sort of new to Kotlin 6-12 Months working on one Android App which is also my first Kotlin/ Mobile / Mutiplatform Project. In the App I work with SQLDelight to manage my Database and Caching. However with new Versions of the Database no Migrations are being made and the App cannot write to Database / Crashes. Now I did try using .sqm files but it does not seem to find the Database Tables.
    b
    s
    • 3
    • 27
  • s

    Saiedmomen

    06/25/2022, 9:12 AM
    I'm trying out the mysql dialect of sqldelight and I see that tables aren't created in initial run.
    java.sql.SQLSyntaxErrorException: Table 'backend_db.record' doesn't exist
    CREATE TABLE record(
        date_time TEXT NOT NULL,
        value INTEGER NOT NULL
    );
    
    insert:
    INSERT INTO record (date_time, value) VALUES (?, ?);
    
    selectRecords:
    SELECT * FROM record;
    Is it expected behavior or am I missing sth in my setup?
    val hikariConfig: HikariConfig = HikariConfig("/hikari.properties").apply {
        validate()
    }
    val hikariDataSource: DataSource = HikariDataSource(hikariConfig)
    val driver: SqlDriver = hikariDataSource.asJdbcDriver()
    val db = Database(driver)
    Also if it is expected behavior, what is the tool to use to initialize the db based on schema?
  • h

    hfhbd

    06/25/2022, 9:49 AM
    Database.Schema.create() or DataBase.Schema.migrate() You don't always want to create a new schema but use the existing one.
    🙏 1
  • j

    Jaime

    06/25/2022, 11:24 PM
    Hi everyone, I am implementing anvil but when I build the project I get this error in the build i have use anvil version 2.4.0 dagger version 2.42 Kotlin 1.6.21
    Execution failed for task ':app:mergeExtDexDevDebug'.
    > Could not resolve all files for configuration ':app:devDebugRuntimeClasspath'.
       > Failed to transform compiler-api-2.4.0.jar (com.squareup.anvil:compiler-api:2.4.0) to match attributes {artifactType=android-dex, asm-transformed-variant=devDebug, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
          > Could not resolve all files for configuration ':app:devDebugRuntimeClasspath'.
             > Failed to transform kotlin-compiler-embeddable-1.6.10.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.6.10) to match attributes {artifactType=android-asm-instrumented-jars, asm-transformed-variant=devDebug, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
                > Execution failed for AsmClassesTransform: /Users/mac/.gradle/caches/transforms-3/13fb0caefbd9f3c68d6e998f61bcf48b/transformed/jetified-kotlin-compiler-embeddable-1.6.10.jar.
                   > JSR/RET are not supported with computeFrames option
       > Failed to transform kotlin-compiler-embeddable-1.6.10.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.6.10) to match attributes {artifactType=android-dex, asm-transformed-variant=devDebug, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
          > Execution failed for AsmClassesTransform: /Users/mac/.gradle/caches/transforms-3/13fb0caefbd9f3c68d6e998f61bcf48b/transformed/jetified-kotlin-compiler-embeddable-1.6.10.jar.
             > JSR/RET are not supported with computeFrames option
    z
    • 2
    • 2
  • h

    hfhbd

    06/26/2022, 6:15 PM
    KotlinPoet: Do you know a possibility to prevent
    CodeBlock.of("${CodeBlock.of("foo")}.bar")
    ? This calls
    CodeBlock.toString()
    and results into wrong imports. You must use
    CodeBlock.of("%L.bar", CodeBlock.of("foo"))
    to keep the arguments of the inner CodeBlock.
    p
    g
    • 3
    • 6
  • s

    Sean Proctor

    06/28/2022, 12:58 PM
    I'm trying to get sqldelight working in an KMM project. Currently it's working well for the Android part, but I'm having some issues with the JVM driver. It seems like there's an issue with running a query in the mapper. Does have an idea of how to handle that?
    a
    • 2
    • 7
  • k

    krzysztof

    06/29/2022, 3:11 PM
    How could I execute pragmas (such as for WAL mode) using delight? I keep getting
    Queries can be performed using SQLiteDatabase query or rawQuery methods only
    from Android driver, either if I run is as labeled statement or just type it in my
    .sq
    schema
    • 1
    • 2
  • k

    Ky

    06/29/2022, 5:54 PM
    Hey Guys, I’m having an issue with SQL Delight JVM test driver. Very similar to issue here https://github.com/cashapp/sqldelight/issues/1329
    No suitable driver found for jdbc:sqlite:
    java.sql.SQLException: No suitable driver found for jdbc:sqlite:
    	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702)
    	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:189)
    This only happens when I run all the tests in a gradle task. If i run the tests individually it works. One thought is to just keep retrying the connection, how could I do this? Thanks
    v
    • 2
    • 1
  • a

    Aidan Low

    06/30/2022, 5:57 PM
    Are there Moshi helpers to manipulate a JSON string directly, for example adding an additional name/value pair, or do I need to call
    fromJson()
    , augment the resulting class with the new pair, and then call
    toJson()
    again?
    z
    • 2
    • 2
Powered by Linen
Title
a

Aidan Low

06/30/2022, 5:57 PM
Are there Moshi helpers to manipulate a JSON string directly, for example adding an additional name/value pair, or do I need to call
fromJson()
, augment the resulting class with the new pair, and then call
toJson()
again?
z

Zac Sweers

06/30/2022, 5:58 PM
not exactly sure I follow what you mean
a

Aidan Low

06/30/2022, 6:11 PM
(a bit more detail in main thread)
View count: 1