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

    saket

    04/29/2020, 10:36 PM
    1) through your buildscript: https://github.com/saket/press/blob/1cf457a099b747e5cbb6debf75a959856f18b4a7/shared/build.gradle#L29
    k
    • 2
    • 1
  • c

    Colton Idle

    05/01/2020, 4:40 AM
    I got a bug report that my app doesn't support chinese characters when saving a user entered field. I thought retrofit + okhttp all operate using utf 8 (note, I'm not super comfortable with text encodings), but it doesn't seem like this is the case. This seems easily googleable, but most of the responses I get on stackoverflow have no answers, and the searching okhttp/retrofit github also has a bunch of questions that get closed without an answer from the author. My googling, might be failing me, but I did try. Am I missing something? Is this not something that okhttp/retrofit handle? Maybe it's moshi that I'm after? Appreciate any pointers.
    z
    • 2
    • 24
  • y

    Yang

    05/02/2020, 10:14 AM
    Just started playing with
    workflow
    today and noticed that
    workflow-ui/core-android
    has both Rx and Coroutines dependencies, are there plans to remove Rx from this artifact?
    z
    • 2
    • 4
  • y

    Yang

    05/03/2020, 8:09 AM
    when using
    workflow
    , what’s the idiomatic / recommended way to handle transient events (a.ka. the single live event issue 😂)?
    z
    r
    • 3
    • 9
  • a

    ahmad

    05/04/2020, 12:52 PM
    I wrote an article about how can we create custom Retrofit CallAdapter to handle the API calls errors and success states. eg
    interface Service {
      @GET("topics/{id}")
      suspend fun topic(): NetworkResponse<Topic, CommentsError>
    }
    
    class Repository {
      val tpoic = service.getTopic()
    
        when (tpoic) {
          is NetworkResponse.Success -> // request succeded
          is NetworkResponse.ApiError -> // request failed
          is NetworkResponse.NetworkError -> // network error
          is NetworkResponse.UnknownError -> // unknown error happened
        }
    }
    https://medium.com/@melegy/create-retrofit-calladapter-for-coroutines-to-handle-response-as-states-c102440de37a
    p
    g
    • 3
    • 2
  • y

    Yang

    05/05/2020, 2:18 PM
    👋 @Zach Klippenstein (he/him) [MOD] My workflow question of the day: can the lifetime of a
    Flow
    worker go beyond a single
    Action
    ? I want to subscribe to a
    Flow
    for the lifetime of a workflow, but it looks like any subsequent
    action
    would cancel the
    Flow
    immediately and you have to re-subscribe to the
    flow
    in the next
    render
    call. I remember reading that it’s possible to subscribe to external event sources, but this is not how I expect
    Flow
    worker to work so I’m probably doing something wrong.
    r
    z
    • 3
    • 5
  • z

    Zac Sweers

    05/08/2020, 8:37 PM
    it’s more likely the first case should be failing too (that property should be marked as transient)
    a
    • 2
    • 2
  • j

    jw

    05/11/2020, 6:06 PM
    No. Converters don't see the whole response object
    b
    • 2
    • 1
  • d

    dimsuz

    05/12/2020, 11:52 AM
    After upgrading to
    sqldelight 1.3.0
    I have this gradle error:
    More than one file was found with OS independent path 'META-INF/runtime.kotlin_module'
    Searching through build folder reveals that sqldelight and 2 other libraries provide this file. SO is full of advices to exclude these from packaging options, but people also note that this would break reflection. I'm a bit hesitant to do that. Is this really a best solution? Should I file a bug somewhere?
    w
    • 2
    • 2
  • f

    Fabian de Almeida Ramos

    05/12/2020, 8:11 PM
    Sorry if this isn’t the right place to ask, but I’m having some trouble with inserting a record without specifying an ID. My table&insert look like:
    CREATE TABLE Recipe (
        id INTEGER PRIMARY KEY AUTOINCREMENT,
        title TEXT NOT NULL,
        duration TEXT NOT NULL,
        difficulty TEXT NOT NULL,
        calories INTEGER AS Int NOT NULL
    );
    
    insert:
    INSERT INTO Recipe (title, duration, difficulty, calories)
    VALUES (?, ?, ?, ?);
    now, when I call
    recipeQueries.insert
    , I get a
    NOT NULL constraint failed: Recipe.id
    .. I’ve been looking around SQLite docs as well, but still can’t figure it out..
    e
    m
    • 3
    • 2
  • e

    Elka

    05/15/2020, 10:17 AM
    Does SqlDelight support
    WITH
    clause? Trying to do something like this:
    WITH existingUser AS (SELECT * FROM user WHERE isRemoved = 0);
    a
    • 2
    • 7
  • d

    Dariusz Kuc

    05/15/2020, 4:13 PM
    [kotlinpoet] Hello! Any hints on how to create generic class reference with wildcard? e.g. given property
    PropertySpec.builder("myProp", ClassName(LIBRARY_PACKAGE, "MyClass")
    how to update it so I end up with
    myProp: MyClass<*>
    Tried using
    parameterizedBy
    with
    WildcardTypeName
    but it looks like it assumes concrete types
    d
    • 2
    • 3
  • d

    dimsuz

    05/17/2020, 11:42 PM
    Is there a way to map errors in Retrofit? Whenever I receive an HttpException I want to parse it and turn it into a more domain specific error exception (
    sealed class MyAppError : Throwable { ... }
    ). I can't find a good place to hook this up. Initially I thought I'd write a
    CallAdapter.Factory
    which simply wraps every adapter, but it needs to somehow get adapter from all other installed factories (itself included) and this'll create a endless recursion.
    d
    • 2
    • 1
  • j

    jw

    05/18/2020, 2:29 PM
    Hmm. Got a full stack trace? Jesse isn't in here. You could always file a bug.
    m
    • 2
    • 1
  • t

    Tolriq

    05/18/2020, 2:42 PM
    API 24 min ?
    m
    • 2
    • 3
  • t

    Tolriq

    05/18/2020, 3:36 PM
    Since @jw is back care to give status update for Moshi future ? 🙂
    j
    c
    j
    • 4
    • 12
  • b

    basher

    05/18/2020, 9:52 PM
    Would supporting fts5 require changes to sql psi?
    d
    • 2
    • 3
  • p

    pvasa

    05/19/2020, 6:05 PM
    Hello everyone, I have some trouble using FTS with sqldelight on Android. It is a multiplatform setup and haven’t tested on ios yet. I have a content table and a fts table pointing to it. Both the tables are populated correctly and I can see all the data when doing
    SELECT *
    on either but when I try to use
    MATCH
    on fts table, it always returns empty dataset. Is there any extra step required to enable fts? Am I missing something for the setup? Below are the queries I use to setup tables Create content table
    CREATE TABLE dbBook (
      isbn INTEGER NOT NULL PRIMARY KEY,
      title TEXT NOT NULL,
      subtitle TEXT NOT NULL DEFAULT '',
      coverUrl TEXT DEFAULT NULL,
      summary TEXT NOT NULL DEFAULT '',
      authorIds TEXT AS List<Long> NOT NULL,
      revisions TEXT AS List<Long> NOT NULL DEFAULT '',
      publishedOn INTEGER as Date DEFAULT NULL,
      addedAt INTEGER as DateTime NOT NULL DEFAULT ((julianday('now') - 2440587.5) * 86400.0 * 1000)
    );
    Create fts table
    CREATE VIRTUAL TABLE dbBookFts
    USING FTS4(
      tokenize=porter,
      content=dbBook,
      isbn INTEGER NOT NULL,
      title TEXT NOT NULL,
      subtitle TEXT NOT NULL,
      summary TEXT NOT NULL
    );
    Triggers to update fts table
    -- Triggers to keep the FTS index up to date.
    CREATE TRIGGER dbBook_bu BEFORE UPDATE ON dbBook BEGIN
      DELETE FROM dbBookFts WHERE isbn=old.isbn;
    END;
    CREATE TRIGGER dbBook_bd BEFORE DELETE ON dbBook BEGIN
      DELETE FROM dbBookFts WHERE isbn=old.isbn;
    END;
    
    CREATE TRIGGER dbBook_au AFTER UPDATE ON dbBook BEGIN
      INSERT INTO dbBookFts(isbn, title, subtitle, summary)
      VALUES(new.isbn, new.title, new.subtitle, new.summary);
    END;
    CREATE TRIGGER dbBook_ai AFTER INSERT ON dbBook BEGIN
      INSERT INTO dbBookFts(isbn, title, subtitle, summary)
      VALUES(new.isbn, new.title, new.subtitle, new.summary);
    END;
    Query for searching
    SELECT dbBook.*
    FROM dbBookFts
    JOIN dbBook ON dbBookFts.isbn = dbBook.isbn
    WHERE dbBookFts MATCH :query;
    Even a simple MATCH query is empty
    SEELCT * FROM dbBookFts WHERE dbBookFts MATCH :query;
    d
    a
    e
    • 4
    • 11
  • j

    jw

    05/20/2020, 11:28 PM
    The dispatcher
    j
    • 2
    • 5
  • e

    Elka

    06/05/2020, 11:25 AM
    Does SQLDelight support
    Temp Views
    ?
    d
    • 2
    • 4
  • s

    Sam Garfinkel

    06/12/2020, 3:03 PM
    Does kotlinpoet-metadata have functionality similar to the
    Types
    and
    Elements
    classes? There’s some reusable functionality that would be nice, such as an
    isSubtypeOf(t1: KmType, t2: KmType
    .
    z
    • 2
    • 9
  • j

    jw

    06/13/2020, 12:13 AM
    I don't recall why
    d
    • 2
    • 3
  • j

    jw

    06/13/2020, 12:13 AM
    You're saying flowOn(context).map(::executeAsOne), right?
    d
    • 2
    • 2
  • b

    Bruno Kongawi

    06/14/2020, 7:10 AM
    In the Android samples/examples of Workflow (https://github.com/square/workflow-kotlin), at each
    showRendering
    click listeners are set (as below).
    override fun showRendering(rendering: Rendering) {
          messageView.setOnClickListener { rendering.onClick(Unit) }
    }
    This means it will be set (unnecessarily) at every
    Rendering
    state change. I don't imagine click listeners to be dynamic very often. What is the reasoning?
    r
    z
    • 3
    • 5
  • a

    alec

    06/17/2020, 6:53 PM
    it is probably not the greatest thing ever that you can do both because its needlessly confusing
    r
    • 2
    • 5
  • a

    alec

    06/17/2020, 7:57 PM
    %L i think
    d
    • 2
    • 1
  • a

    andev

    06/19/2020, 4:13 PM
    Tried it, but not so lucky. This:
    val schema = object : SqlDriver.Schema by Database.Schema {
        override fun migrate(driver: SqlDriver, oldVersion: Int, newVersion: Int) {
            appContext.deleteDatabase("mydatabase.db")
            Database.Schema.create(driver)
        }
    }
    Throws this:
    W/SQLiteLog: (28) file unlinked while open: /path/to/mydatabase.db
    android.database.sqlite.SQLiteReadOnlyDatabaseException: attempt to write a readonly database (code 1032)
            at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native Method)
            at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:736)
            at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
            at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
            at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1756)
            at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1683)
            at android.database.sqlite.SQLiteDatabase.setVersion(SQLiteDatabase.java:950)
            at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:341)
            at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:238)
            at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:145)
            at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:106)
            at com.squareup.sqldelight.android.AndroidSqliteDriver$database$2.invoke(AndroidSqliteDriver.kt:30)
            at com.squareup.sqldelight.android.AndroidSqliteDriver$database$2.invoke(AndroidSqliteDriver.kt:19)
            at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
            at com.squareup.sqldelight.android.AndroidSqliteDriver.getDatabase(Unknown Source:2)
            at com.squareup.sqldelight.android.AndroidSqliteDriver.newTransaction(AndroidSqliteDriver.kt:82)
            at com.squareup.sqldelight.TransacterImpl.transactionWithWrapper(Transacter.kt:208)
            at com.squareup.sqldelight.TransacterImpl.transaction(Transacter.kt:197)
            at com.squareup.sqldelight.Transacter$DefaultImpls.transaction$default(Transacter.kt:82)
    d
    • 2
    • 1
  • m

    Myroslav Kolodii

    06/26/2020, 2:26 PM
    Has anyone tried to use SqlDelight's flow extension on Native lately? I have a multiplatform project (Android/iOS), where flow is working w/o issues on Android, but not on iOS. No related logs or crashes. SqlDelight version 1.4.0 (tried with 1.3.0 as well)
    a
    k
    • 3
    • 5
  • a

    andev

    06/26/2020, 3:01 PM
    That's a bug
    Pls file an issue
    can anyone create that issue for me, please
    a
    • 2
    • 2
  • j

    jw

    07/01/2020, 5:18 PM
    they are synchronous so use
    withContext
    👍 3
    m
    • 2
    • 7
Powered by Linen
Title
j

jw

07/01/2020, 5:18 PM
they are synchronous so use
withContext
👍 3
m

Mustafa Ozhan

07/19/2022, 9:13 AM
@jw what about when we request as flow ? will
fun getActiveCurrencies() = currencyQueries
        .getActiveCurrencies()
        .asFlow()
        .flowOn(ioDispatcher)
        .mapToList(ioDispatcher)
be enough ? or should we still call with
withContext
like this?
suspend fun getActiveCurrencies() = withContext(ioDispatcher) {
        currencyQueries
            .getActiveCurrencies()
            .asFlow()
            .flowOn(ioDispatcher)
            .mapToList(ioDispatcher)
    }
j

jw

07/19/2022, 12:58 PM
Remove flowOn
Also withContext
Also suspend
m

Mustafa Ozhan

08/07/2022, 10:54 PM
Thanks a lot for the answers! Removing
withContext
and
suspend
makes perfect sense, but I confused about removing the
flowOn(ioDispatcher)
is SQLDelight emitting value changes on IO thread ?
j

jw

08/07/2022, 10:56 PM
You pass a dispatcher to the map function which is where the query is executed
m

Mustafa Ozhan

08/07/2022, 11:00 PM
Ohh right, the rest actually doesn’t require the context in terms of the querying 👍 Thanks a lot!
View count: 5