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
  • c

    Colton Idle

    09/06/2021, 10:56 PM
    Does square/cashapp libraries follow any sort of changelog/readme conventions for how to ship with a release? I'm following a more CI/CD workflow at a new company I'm at, and we want an automated way to generate the release notes after a build is created. We sorta decided on having a bunch of empty lines in an
    UNRELEASED.md
    and when the CI goes off, it takes everything there and puts it in release notes (like how gitlab does it: https://about.gitlab.com/blog/2018/07/03/solving-gitlabs-changelog-conflict-crisis/) I can't help to think that library developers (since releases are typically infrequent) have some sort of system in place as well where documentation/markdown is updated with a PR rather than just keeping track of changes in their notes and then writing out those notes fully just in time when a release is created.
    e
    j
    • 3
    • 3
  • m

    myanmarking

    09/10/2021, 3:05 PM
    is there any way to perform a query that returns 1 or 0, but parse it as boolean in the generated model ?
    b
    a
    • 3
    • 6
  • j

    jw

    09/14/2021, 1:14 AM
    What hash? Okio has some of those built in
    s
    • 2
    • 9
  • w

    William Reed

    09/23/2021, 9:09 PM
    looking at
    TypeMirror.asTypeName()
    from kotlin poet suggests using
    kotlinpoet-metadata
    instead. looking through the docs i don’t really see how I can perform the same type of operation from within an annotation processor on an
    Element
    to get a type name. any suggestions?
    e
    • 2
    • 2
  • c

    Colton Idle

    09/26/2021, 4:01 AM
    Can I get a quick code review on my authorization interceptor for retrofit? It's not a network interceptor, but an application interceptor
    class RollerToasterAuthInterceptor @Inject constructor(val userManager: UserManagerService) :
        Interceptor {
        override fun intercept(chain: Interceptor.Chain): Response {
            val originalRequest: Request = chain.request()
            val compressedRequest: Request =
                originalRequest
                    .newBuilder()
                    .header("authorization", "Bearer " + userManager.authToken)
                    .method(originalRequest.method, originalRequest.body)
                    .build()
            return chain.proceed(compressedRequest)
        }
    }
    y
    n
    • 3
    • 4
  • c

    Colton Idle

    09/27/2021, 10:41 PM
    Going off of the above... if I have a single retrofitApiService instance, then acquire an auth token (because I logged in)... how would I go about adding it to my interceptor? Or is there basically no away around just creating a new retrofit service so that I can properly add the new auth interceptor after logging in?
    b
    n
    • 3
    • 4
  • a

    aiidziis

    10/04/2021, 8:32 AM
    Hey! I went trough Anvil sample application where
    generateFactories
    is enabled and tried to replicate the same setup but stumbled on issue:
    symbol:   class CategoriesModule_GetFragmentFactory
    location: package com.test.catalogcategories.dependency/Users/test/Desktop/Test/test-android/app/build/generated/source/kapt/debug/com/test/app/di/DaggerApplicationComponent.java:97: error: cannot find symbol
    import com.test.catalogfavoriteproducts.dependency.FavoriteProductsModule_GetFragmentFactory;
    ✅ 1
    • 1
    • 2
  • i

    itnoles

    10/10/2021, 8:54 PM
    How I can set constructors on TypeSpec.anonymousClassBuilder()?
    m
    e
    • 3
    • 11
  • b

    Benoit Quenaudon

    10/19/2021, 1:11 PM
    Indeed I think there's a bug in there and for now the workaround would be to generate your types with
    javaInterop = true
    ➕ 1
    f
    • 2
    • 5
  • j

    jean

    10/22/2021, 9:33 AM
    When I run each unit test function (tests for sqldelight related read and writes operations) of my class with the gutter icon next to them for android and ios target (kmm project) they all complete successfully. When I run the test from the gutter icon at the class level, it works fine for android but I get the following error for ios :
    executeNonQuery error | error code SQLITE_CONSTRAINT
    co.touchlab.sqliter.interop.SQLiteExceptionErrorCode: executeNonQuery error
    Invalid connection: com.apple.coresymbolicationd
    I do clean up my test database after each test, should I do one more specific clean up at some point?
    • 1
    • 1
  • j

    jessewilson

    10/23/2021, 6:56 PM
    😛arty-parrot: Okio 3.0.0 final is coming this week… The update adds a bunch of new types: • FileSystem (including many implementations:
    SYSTEM
    ,
    RESOURCES
    , Zip, Fake, and Forwarding) • Path • FileMetadata • FileHandle If you’d like to take a look at the API and offer feedback, now is the time! We’ll be very limited in what we can change once we ship 3.0 final! Send feedback directly to me or our issue tracker.
    :party-parrot: 2
    🎉 23
    c
    • 2
    • 3
  • j

    jean

    10/25/2021, 6:50 PM
    Running this simple test on android target works but crashes on ios with the following error
    kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlin.Array
    @Test
    fun `test transaction`() {
        queries.transaction {
    
        }
    }
    What am I missing here?
    🤔 1
    s
    c
    • 3
    • 5
  • m

    mbonnin

    10/27/2021, 2:35 PM
    Something like below should do:
    FileSpec.builder(packagename, filename)
    	.addType(TypeSpec.interfaceBuilder("I").addTypeVariable(TypeVariableName("T")).build())
    	.addType(TypeSpec.classBuilder("C").addSuperinterface(ClassName(packageName, "I").parameterizedBy(String::class.java.asClassName())).build())
    	.build()
    :nice: 1
    l
    • 2
    • 1
  • m

    mbonnin

    10/27/2021, 2:36 PM
    The trick is that I don't think you can reference a "file-local" interface so it needs to know the
    packageName
    in
    ClassName(packageName, "I")
    above
    l
    • 2
    • 1
  • l

    LastExceed

    10/27/2021, 5:37 PM
    thats why it looks different depending on your theme and condext, what you see is actually the background
    t
    • 2
    • 5
  • l

    LastExceed

    10/27/2021, 6:05 PM
    is this a bug? cuz
    get
    is a valid function name
    i
    • 2
    • 1
  • s

    smallshen

    10/29/2021, 8:35 PM
    Will okhttp have Kotlin multi platform support?
    e
    • 2
    • 2
  • c

    Colton Idle

    11/05/2021, 1:50 PM
    Possibly a dumb question, but when using okhttp is there a way to view the expiration date of the tls cert? Weird ask/requirement from my security team is to build something in the app where you can see the exp date of tls certs, and I'm kinda out of my league when it comes to tls/certs. I do think this is a super weird request though.
    a
    e
    • 3
    • 3
  • d

    dimsuz

    11/08/2021, 3:55 PM
    Another okhttp question: while using
    HttpLoggingInterceptor
    sometimes I have to deal with polling `GET`s which get executed every 2 seconds, and they spam log a lot. I understand that there's no ready solution to disable logging on a per-url basis or to rate limit logs, but maybe I've missed something? Asking before I invent my own 🙂
    n
    m
    • 3
    • 5
  • h

    Hakob Astvacatryan

    11/10/2021, 3:44 PM
    Hey folks, we are investigating Anvil as a DI solution. Is there a way to not add inject function to components for every activity or fragment and use some kind of generic solution?
    r
    n
    • 3
    • 6
  • b

    benkuly

    11/11/2021, 8:09 AM
    Is it possible to prevent
    AndroidSqliteDriver
    from creating the schema? My common code just wants a driver and uses it to create the schema and do migration stuff.
    a
    • 2
    • 2
  • r

    rachael

    11/16/2021, 8:45 PM
    Looking at https://github.com/square/okhttp/issues/3251 and https://github.com/square/okhttp/issues/6453, both mention that OkHTTP v5 will include changes to handle corrupted cache states more gracefully. Can you say whether OkHTTP v5 will be backwards compatible for use with Retrofit 2.9.0? We have some clients currently on OkHTTP 4.9.1 running into this issue.
    y
    • 2
    • 1
  • j

    jw

    11/17/2021, 5:21 AM
    have you seen the conversation from earlier today above?
    r
    • 2
    • 1
  • t

    Trevor Stone

    11/22/2021, 8:52 PM
    Any chance we can get a point release of SQLdelight with https://github.com/cashapp/sqldelight/pull/2649 included. It seems to be the last thing needed for M1 support in our project
    ➕ 2
    j
    • 2
    • 1
  • h

    Humphrey

    11/23/2021, 4:46 PM
    Hello all, I'm trying to setup SQLDelight for a Compose project (Kotlin). When I follow the website I'm getting stuck at configuring the database. I have done the following: 1. imported the gradle plugin
    plugins {
        kotlin("jvm") version "1.5.31"
        id("org.jetbrains.compose") version "1.0.0-beta5"
        id("com.squareup.sqldelight") version "1.5.2"
    }
    2. added the driver dependency
    dependencies {
        implementation(compose.desktop.currentOs)
        implementation("com.squareup.sqldelight:sqlite-driver:1.5.2")
    
        testImplementation(kotlin("test"))
    }
    3. now I'm trying to add the configuration for the gradle-plugin
    sqldelight {
      Database { // This will be the name of the generated database class.
        packageName = "com.example"
      }
    }
    But I get error
    sqldelight {
        sqldelight.com.squareup.sqlite.migrations.Database {
    
        }
    }
    The error:
    build.gradle.kts:47:16: Unresolved reference: com
    SQLDelight Gradle plugin was applied but there are no databases set up.
    Seems like I'm not able to add Database like that (com is pointing out to the package name and marked red in my Intellij). If I remove the package name (sqldelight.
    com
    .squareup.sqlite.migrations) it does not work. Hope someone can help me out with this?
    m
    s
    • 3
    • 11
  • p

    Philip Dukhov

    11/24/2021, 1:22 AM
    I'm using MySQL. After updating to 1.5.3, for a column called
    value
    kotlin generated name is
    value_
    . In 1.5.2 it was
    value
    SQL code:
    CREATE TABLE Test (
        value INTEGER NOT NULL
    );
    Produces:
    public data class Test(
      public val value_: Int
    ) {
      public override fun toString(): String = """
      |Test [
      |  value_: $value_
      |]
      """.trimMargin()
    }
    Is this expected behaviour?
    :yes: 1
    p
    • 2
    • 2
  • m

    mbonnin

    11/25/2021, 6:55 PM
    Is there a specific reason there is no
    fun String.source(): Source
    like there is
    fun File.source(): Source
    ?
    // This works
    File(path).source().buffer()
    // This doesn't
    "Hello World".source().buffer()
    j
    j
    • 3
    • 18
  • a

    alec

    11/26/2021, 12:36 PM
    So you would follow that guide
    r
    • 2
    • 2
  • r

    Rahul Rawat

    11/29/2021, 2:52 PM
    I tried using the native sqlite driver for the desktop platforms and the attached error is coming while the same NativeSqliteDriver is working fine with iOSMain (I need these separate since KTOR client for iOS and desktop are separate). Also attached is my build gradle file. Can anyone please help out?
    build.gradle.kts
    a
    • 2
    • 3
  • a

    ankushg

    11/30/2021, 1:37 AM
    Hey friends! Does anyone have an example of handling polymorphic models with SQLDelight? I found this example from around 5 years ago -- is it still the recommended approach?
    a
    • 2
    • 5
Powered by Linen
Title
a

ankushg

11/30/2021, 1:37 AM
Hey friends! Does anyone have an example of handling polymorphic models with SQLDelight? I found this example from around 5 years ago -- is it still the recommended approach?
a

alec

11/30/2021, 1:50 AM
I would say we intentionally don’t do any fancy OOP with the generated code to keep the library and its usage simple, I do use polymorphic types sometimes but I always create them in kotlin by selecting the data I need and then using the query function which takes a mapper
👍 1
So as soon as you want complex types, better to define them in kotlin and map to them manually
a

ankushg

11/30/2021, 1:56 AM
Makes sense -- I was (eventually) planning on mapping to my own types anyway Do you usually do 1. one big table with the union of all subtype fields + some discriminator, 2. a unique, self-contained table per subtype 3. a table with the parent class + separate tables for each subtype with ids as foreign keys to the parent-class table 4. something else I can't think of Does one of those approaches work better with Kotlin-side mapping than another?
a

alec

11/30/2021, 2:34 AM
We usually have something like 3 or 4 tables that get joined, and the columns that are nullable indicate what type to make it (the phone number is null so this is an email recipient, that kind of thing), however joins can get hairy. My general rule of thumb is to have the tables be easy to insert into since queries are easier to scale: so if you have all your data coming from one endpoint, it goes into one table, that kind of thing. I don’t like having multiple sources of truth for a table (like two separate classes modifying the same table). Hopefully that helps - essentially keep the writes super simple and let the queries be more complex
➕ 1
a

ankushg

11/30/2021, 2:45 AM
Makes sense! Thanks 🙂
View count: 7