https://kotlinlang.org logo
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
  • j

    jw

    03/20/2019, 10:33 PM
    CoroutineCallAdapterFactory
    is not a thing
    g
    • 2
    • 5
  • j

    jw

    03/24/2019, 5:10 PM
    Take a look at how the polymorphic adapter is implemented in the repo
    d
    • 2
    • 1
  • d

    dave08

    03/24/2019, 6:26 PM
    Thanks! It's a bit longer than what I had before... but I guess it's probably better. I still wonder if there might not be a use case for a Factory on what I mentioned before...
    e
    • 2
    • 2
  • e

    Ellen Shapiro

    03/25/2019, 11:03 AM
    Hi - I’ve run into this issue with SQLDelight: https://github.com/square/sqldelight/issues/1260 and I’m a bit confused about how to work around it to get the code to be added to the
    commonMain
    module instead of the
    iosMain
    module. Does anyone more details on how I can get that to work?
    a
    • 2
    • 3
  • d

    dave08

    03/25/2019, 11:44 AM
    In Moshi, is
    KotlinJsonAdapterFactory
    needed for Kotlin CodeGen, or is it only used for reflection mode?
    e
    • 2
    • 2
  • k

    kpgalligan

    03/25/2019, 1:54 PM
    So, I can refactor that sample and just pull it out. @Ellen Shapiro, safely ignore that and just pull the list directly into Swift, but you’ll want to figure out a concurrency plan for real apps, obviously. That will likely involve freezing, although the data itself may not need to be.
    e
    • 2
    • 10
  • d

    dave08

    03/27/2019, 4:22 PM
    Is there any problem with this Moshi Adapter, it doesn't seem like Moshi is using it at all...
    class IdAdapter {
    	private val logger = KotlinLogging.logger {}
    
    	@FromJson
    	@OdooIdentityId
    	fun fromJson(value: Any): Int? = when (value) {
    		is Boolean -> null
    		is Double -> value.toString().toInt()
    		is Int -> value
    		is ArrayList<*> -> checkArrayValue(value.first()!!)
    		else -> throw IllegalStateException("Non-object-non-boolean value for @OdooIdentityId field $value")
    	}
    
    	@ToJson
    	fun toJson(@OdooIdentityId value: Int?): String = TODO()
    
    	private fun checkArrayValue(value: Any): Int? = when(value) {
    		is Boolean -> null
    		is Double -> value.toInt()
    		is Int -> value
    		else -> error("Invalid Odoo identity $value")
    	}
    }
    b
    • 2
    • 9
  • d

    Dico

    03/28/2019, 6:50 PM
    I like the idea of it generating code based on queries - are there other libraries that do that?
    b
    • 2
    • 6
  • j

    jw

    03/30/2019, 7:53 PM
    Yes. There's an Rx extension
    m
    • 2
    • 4
  • d

    dave08

    03/31/2019, 2:29 PM
    I mean like \xxxx unicode codepoints for all non-ascii characters... in old Android devices, it seems like SharedPreferences can't take those chars, so I need my api (using Moshi) to send these as escaped strings.
    l
    • 2
    • 1
  • a

    alec

    04/20/2019, 12:59 PM
    If you run into anything I can try to help out here
    p
    • 2
    • 1
  • k

    kevin.cianfarini

    04/21/2019, 6:25 PM
    Can anyone shed some light on why the `asFlow`extension for SQLDelite is written using a channel? I understand how it works, but I feel like I'm missing the reasoning for why we need a channel.
    fun <T : Any> Query<T>.asFlow(): Flow<Query<T>> = flow {
      val channel = Channel<Unit>(CONFLATED)
      val listener = object : Query.Listener {
        override fun queryResultsChanged() {
          channel.offer(Unit)
        }
      }
      addListener(listener)
      try {
        emit(this@asFlow)
        for (item in channel) {
          emit(this@asFlow)
        }
      } finally {
        removeListener(listener)
      }
    }
    
    
    // why do we need the Channel?
    fun <T : Any> Query.asFlow(): Flow<Query<T>> = flow {
      val listener = object : Query.Listener {
        override fun queryResultsChanges() {
          emit(this@asFlow)
        }
      }
    
      addListener(listener)
      try {
        emit(this@asFlow)
      } finally {
        removeListener(listener)
      }
    }
    d
    • 2
    • 1
  • m

    Mark

    04/28/2019, 7:18 AM
    So, I’m writing an Android app in Kotlin currently using Room for SQLite. At some point in the future I want to use as much of the Kotlin code as possible in an iOS version. So I’m considering migrating from Room to SQLDelight. Is this a no-brainer? Is there any reason why I should stick with Room for now (perhaps wait and see how the landscape changes in the next 6 months) or is it a case of sooner-the-better? #room
    k
    • 2
    • 4
  • d

    dave08

    05/08/2019, 1:50 PM
    What's the difference between java and javaObjectType on KClass? I need to use this type for getting Moshi's converter, is there any preference? Like
    moshi.adapter<Any>(type.javaObjectType)
    .
    e
    e
    • 3
    • 5
  • e

    eric

    05/10/2019, 11:14 PM
    if the provided Moshi PG or R8 configuration file isn't working, probably report on the GH issue tracker
    r
    • 2
    • 4
  • a

    alec

    05/22/2019, 2:32 PM
    did you turn that flag off
    m
    • 2
    • 3
  • a

    alec

    05/24/2019, 12:14 PM
    it depends on what you're using the data for. SQLDelight is purposely trying to incentivize not doing SELECT * everywhere and especially not SELECT * FROM x JOIN y If you really need all the columns from both tables for every single row, then definitely do a single query. If you're just trying to get table types back from sqldelight ( 😞 ) then use 2 separate queries
    d
    • 2
    • 1
  • d

    dimsuz

    05/27/2019, 5:58 PM
    Hi! Can anyone help me an diagnose sqldeligt issue? I have
    CREATE VIEW series_full AS
    SELECT series.id, series.name
    FROM series
    JOIN series_category ON series_category.id = series.id
    ORDER BY rowid ASC;
    
    find_one_by_id:
    SELECT *
    FROM series_full
    WHERE id = ?;
    I get an exception:
    SQLiteException: no such table: series_full (code 1): , while compiling: SELECT * FROM series_full  WHERE id = ?1
    y
    a
    • 3
    • 11
  • d

    dave08

    06/05/2019, 1:12 PM
    Is there any reason why Kotshi is still being managed even though Moshi already has Kotlin Codegen? If so, shouldn't they just be merged or something?
    g
    • 2
    • 6
  • y

    yshrsmz

    06/06/2019, 6:25 AM
    In SQLDelight, what is the best way to use PRAGMA in multiplatform project? Extending
    SqlDrive.Schema
    and manually execute PRAGMA statement in
    create
    function? I found this issue(https://github.com/square/sqldelight/issues/1241 ), but it does not cover multiplatform.
    d
    • 2
    • 17
  • l

    louiscad

    06/07/2019, 12:26 PM
    With Retrofit 2.6.0, I still get
    kotlin.KotlinNullPointerException: Response from xxx was null but response body type was declared as non-null
    , including after moving to
    suspend fun
    . What may cause
    Unit
    to be improperly handled even though it's advertised as supported?
    • 1
    • 1
  • a

    alec

    06/08/2019, 8:31 PM
    https://github.com/square/sqldelight/issues/1243
    👍 1
    🙏 1
    j
    • 2
    • 2
  • n

    Nikky

    06/11/2019, 10:40 PM
    not sure where else to report: the sqldelight idea plugin seems to be giving me trouble: https://gist.github.com/NikkyAI/14ac1a5cee780561c0270f98e68db1e3
    a
    • 2
    • 2
  • h

    hmole

    06/20/2019, 5:48 AM
    @jw Can I specify
    BufferedSource
    as a return type of retrofit interface function?
    j
    • 2
    • 4
  • y

    yshrsmz

    06/21/2019, 7:33 AM
    I've been experimenting SQLDelight's new FlowExtensions in Kotlin/Native, and it turned out not working as
    offer
    is called directly inside frozen
    Query.Listener
    .
    • 1
    • 2
  • a

    alec

    06/22/2019, 2:16 PM
    If that doesn't work try src/main/sqldelight
    c
    • 2
    • 21
  • g

    gildor

    06/24/2019, 6:04 AM
    @hmole
    call.execute()
    is bad idea, it make request non cancellable, better to use call.await() without any additional async wrappers. And if someone really want to share threads between coroutine dispatchers and OkHttp it’s better to write some custom OkHttp dispatcher, but not sure that it worth it
    things like
    runBlocking and ThreadContextElement
    work correctly with it
    runBlocking will work correctly. Not 100% sure how ThreadContextElement works, but as I understand it also should work, this is the whole point of this context
    h
    • 2
    • 5
  • j

    jw

    06/24/2019, 2:40 PM
    2.7 will require Java 8 which means we can use a default method on converters to handle this case
    d
    • 2
    • 5
  • p

    Paul Woitaschek

    06/28/2019, 10:46 AM
    May I draw some attention to this? I just migrated a lot of code to suspend functions and now my app crashes randomly with
    UndeclaredThrowableException
    https://github.com/square/retrofit/issues/3128
    j
    • 2
    • 4
  • c

    coletz

    07/01/2019, 9:44 AM
    Here again with some problem. I have a common module with sqldelight generated code, but it complains that it can't find sqldelight classes (like SqlDriver). I tried adding
    com.squareup.sqldelight:runtime
    and nothing changed. I tried adding also
    com.squareup.sqldelight:runtime-metadata
    and now the IDE shows everything ok, but the compiler still says that it can't find sqldelight classes. Anyone know what can I try?
    • 1
    • 1
Powered by Linen
Title
c

coletz

07/01/2019, 9:44 AM
Here again with some problem. I have a common module with sqldelight generated code, but it complains that it can't find sqldelight classes (like SqlDriver). I tried adding
com.squareup.sqldelight:runtime
and nothing changed. I tried adding also
com.squareup.sqldelight:runtime-metadata
and now the IDE shows everything ok, but the compiler still says that it can't find sqldelight classes. Anyone know what can I try?
Never mind. Was missing js lib
View count: 15