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
exposed
  • w

    wouterdoeland

    01/19/2018, 4:49 PM
    Why is this throwing a
    JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL)
    while close on exit = false is already set?
    @Before
        fun setupDatabase() {
            Database.connect("jdbc:h2:mem:test;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1", "org.h2.Driver")
    
            // create tables
        }
    
        @After
        fun tearDownDatabase() {
            transaction {
                exec("SHUTDOWN;")
            }
        }
    t
    • 2
    • 3
  • a

    apomelov

    01/22/2018, 9:50 AM
    Hi. I was looking for a library like Exposed but found as well @orangy’s squash at https://github.com/orangy/squash. What's the relation between these projects?
    ✅ 1
    ☝️ 1
    t
    d
    • 3
    • 3
  • o

    oshai

    01/23/2018, 1:45 PM
    https://dev.mysql.com/doc/refman/5.7/en/logical-operators.html#operator_not
    t
    • 2
    • 3
  • w

    wouterdoeland

    01/23/2018, 5:16 PM
    For some reason when calling a field with text type in H2,
    org.h2.jdbc.JdbcSQLException: The object is already closed
    is thrown. At:
    val map = transaction { loggedRequest.parameters } // throws exception
    val map = transaction { loggedRequest.method } // doesn't throw exception
    For:
    object ApiLogs : IntIdTable() {
        ...
        val parameters = text("parameters")
        val method = varchar("method", 191)
        ...
    }
    
    class ApiLog(id: EntityID<Int>) : IntEntity(id) {
        companion object : IntEntityClass<ApiLog>(ApiLogs)
    
        ...
        var parameters by ApiLogs.parameters
        var method by ApiLogs.method
        ...
    }
    t
    • 2
    • 3
  • d

    dave08

    01/25/2018, 8:51 PM
    If I have an existing postgres schema managed by a python framework, but would like my api to do CRUD on only part of the schema, can I just declare part of it in exposed at use only the part I need? I just need CRUD, not that it should change the structure at all...
    t
    • 2
    • 3
  • d

    dumptruckman

    01/25/2018, 10:19 PM
    For the DAO method, when do updates occur? The wiki says '"Flushing" values to the database occurs at the end of the transaction or before next "select *" from the database.' What happens if I change my object outside of a transaction statement?
    t
    • 2
    • 1
  • d

    dave08

    01/26/2018, 10:24 AM
    Also, coroutine support could still be for non async using a thread pool, at least until there would be an async solution... otherwise anyone using this with Ktor will have to surround everything with
    async { }.await()
    and make their own thread pools... I have a coroutine utils package in most of my projects for such things that I keep having to copy... it would be great if it could be integrated into the lib...
    🤔 1
    t
    • 2
    • 2
  • w

    wouterdoeland

    01/26/2018, 1:39 PM
    Hi, why am I getting this error:
    [14:31:02 ERROR]: [Exposed] mysql 5.5 doesn't support expression '(CURRENT_TIMESTAMP)' as default value. Column will be created with NULL marker.
    . I'm using MariaDB 10.1.26.
    t
    • 2
    • 3
  • d

    damian

    01/27/2018, 9:00 PM
    i'm working with DAOs. i have a table that has a foreign key /
    optionalReferencedOn
    , is it possible in a query to access the referenced object? (for example
    User
    has a reference to
    City
    , and
    City
    has a column
    Inhabitants
    and i want to get all users living in a
    city
    with at least 5k inhabitants) (typing it, it seems like it would be a better approach from "the other side" (looking for cities with inhabitants and getting all
    users
    that have a reference to those cities, but not sure how i'd do that either atm)
    t
    • 2
    • 1
  • o

    oshai

    01/28/2018, 2:45 PM
    in case I would like to use a column with whole number that is bigger than
    long
    , what are my options?
    decimal
    ?
    t
    • 2
    • 2
  • d

    dave08

    01/28/2018, 3:33 PM
    Is there a way to retreive only an sql statement w/o running it (to be executed w/ another library...)?
    t
    • 2
    • 1
  • n

    nekoinemo

    02/20/2018, 3:18 PM
    Hi. I feel like i asked this already long time ago, but: how do i create multi-column PK (i.e. for many-to-many join tables)? do i just call primaryKey() on all required columns? ... It does.
    t
    • 2
    • 1
  • w

    wouterdoeland

    02/23/2018, 8:20 AM
    Hi! I'm getting this very annoying exception:
    Caused by: java.sql.SQLException: Multiple primary key defined
    Query is: ALTER TABLE Clans MODIFY COLUMN id INT AUTO_INCREMENT PRIMARY KEY
    Does anyone know why this is happening? This happens everytime I run
    SchemaUtils.createMissingTablesAndColumns(Clans)
    with Clans or with any other table.
    t
    • 2
    • 3
  • o

    oshai

    02/26/2018, 12:35 PM
    @tapac - after upgrading to 0.10.1 the following do not compile:
    transaction(statement)
    t
    • 2
    • 8
  • t

    tapac

    02/26/2018, 1:02 PM
    In your case you should use
    insertAndGetId
    When you write
    insert[id]
    you try to get value related to "expression" from resultSet. It can be null if, for example, it wasn't inserted, that's why column type (not-nullable) doesn't make sense.
    z
    • 2
    • 4
  • z

    ziad

    03/02/2018, 5:19 PM
    This is what I went for, is there a cleaner or more idiomatic way to do it?
    return transaction {
               //Check if a user with this device id exists       
                val userIdEntity = Users.select {
                    Users.deviceId eq deviceId
                }.map { it[Users.id] }.firstOrNull()
    
                //Assign the user id 
                val userId =
                        if(userIdEntity != null) {
                            userIdEntity.value
                        } else
                        {
                            Users.insertAndGetId {
                            //...
                            }.value
                        }
            }
    t
    • 2
    • 1
  • a

    avolkmann

    03/03/2018, 12:16 PM
    Is there a way to select isNull() ?
    t
    • 2
    • 2
  • n

    niteesh

    03/05/2018, 11:44 AM
    I am able to achieve a connection pool to my database using SpringTransactionManager(dataSource) . But as my dao layer use transaction { } blocks, I get the IllegalStateException: Already value for key bound to thread [main]
    t
    • 2
    • 6
  • m

    mattiascrofani

    03/09/2018, 11:18 AM
    Hello there. Real noob here with kotlin and exposed. I'm trying to run a simple join but clearly I'm missing something obvious so I was trying to recreate what I read on the wiki. AccessToken.idStaff and Staff.id are both int. The exception says that "Cannot join as there is no matching primary key/ foreign key pair and constraint missing". Isn't that "select" the condition for the join?
    (AccessToken innerJoin Staff).slice(Staff.id, Staff.userName).select {AccessToken.idStaff eq Staff.id}
    t
    • 2
    • 2
  • b

    betterclever

    03/11/2018, 11:56 AM
    Is there any way to map them to Inspection Entity object directly?
    t
    • 2
    • 1
  • o

    oshai

    03/11/2018, 4:15 PM
    I get this error:
    ... don't have client default values. DB defaults don't support in batch inserts
    why is that not supported?
    t
    • 2
    • 11
  • b

    betterclever

    03/11/2018, 4:36 PM
    I am not sure why does it have an extra phone in the create statement.
    t
    • 2
    • 2
  • z

    zjor

    03/12/2018, 9:28 PM
    Hi! I'm starting with kotlin+exposed, how does the Database object got passed to transaction {} method?
    Database.connect("<url>", driver = "org.postgresql.Driver", user = "..", password = "...")
    transaction {
    and which is the common approach to initialise Database, so I don't create it in each service method? Thanks in advance
    t
    • 2
    • 1
  • t

    tmseiler

    03/13/2018, 10:15 PM
    Is there something like Django's "Q" object?
    t
    • 2
    • 6
  • a

    avolkmann

    03/14/2018, 12:50 PM
    this doesn't compile anymore after updating:
    ResultRow.get(Max(Table.id, IntegerColumnType()))
    t
    • 2
    • 5
  • n

    Nate Mara

    03/15/2018, 10:54 PM
    Hello, I'm new to Kotlin and Exposed, and I'm having some difficulty with the DAO api. I'm trying to create a function that will have a where clause that is different depending on runtime user input. I don't appear to be able to use any if blocks inside the transaction block. I'm trying to do something like this:
    fun findX(xGt: BigDecimal?, xLt: BigDecimal?): List<DaoClass> {
        return transaction {
            DaoClass.find {
                var condition = TableClass.any()
                if (xGt != null) {
                    condition = condition.and(TableClass.x.greater(xGt))
                }
                if (xLt != null) {
                    condition = condition.and(TableClass.x.less(xGt))
                }
    
                condition
            }.toList()
        }
    }
    Is this possible?
    t
    • 2
    • 1
  • a

    aeruhxi

    03/27/2018, 4:44 PM
    can DAO do everything DSL can?
    t
    • 2
    • 1
  • m

    mkporwit

    03/29/2018, 10:53 PM
    Is there a way to specify the encoding for certain columns? Specifically, I’m looking to tell MySQL that some columns are utf8mb4. In case it matters, we’re using the DAO approach.
    t
    • 2
    • 2
  • m

    mkporwit

    04/02/2018, 7:12 PM
    Rather than using the implicit Orgs id, I want to reference on the Orgs (and Users) uid, which is a unique string. What’s the proper syntax for defining OrgMembership in that case? IntelliJ complains that
    val org by Org referencedOn OrgMemberships.orgId
    has a type mismatch, where it expects a
    Column<EntityId<Int>>
    but gets a
    Column<EntityId<String>>
    . How do I tell OrgMembership to use that string?
    t
    • 2
    • 6
  • a

    alex.rios

    04/04/2018, 7:08 PM
    Hey guys! How use a table named with underscore? User_Profile is mapped using UserProfile? (supressing the underscore maintaining camel case)
    t
    • 2
    • 1
Powered by Linen
Title
a

alex.rios

04/04/2018, 7:08 PM
Hey guys! How use a table named with underscore? User_Profile is mapped using UserProfile? (supressing the underscore maintaining camel case)
t

tapac

04/05/2018, 12:27 PM
Just provide explicit table name you like in Table constructor.
View count: 1