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

    Shawn A

    08/21/2019, 2:16 PM
    I am using an
    alias
    to create a sub-query and then using that sub-query in a join. It looks like once you use an
    alias
    you can no longer reference the columns in the
    ResultRow
    by the original table's columns. Keys in the
    ResultRow
    from the alias look like
    org.jetbrains.exposed.sql.Alias.name
    . Is there any way to avoid this? I have common mapping code that assumes it can use the table class to reference columns. e.g (
    DataSourceTable.name
    ).
    t
    • 2
    • 2
  • k

    Kevin Schmeichel

    08/21/2019, 6:05 PM
    It appears that version
    17.1
    has broken the mysql
    MATCH(...) AGAINST(...)
    function - now the generated sql looks like this:
    MATCH(... AGAINST(...)
    . no closing right
    )
    on the MATCH.
    t
    • 2
    • 1
  • s

    Shawn A

    08/22/2019, 3:18 PM
    Is there an example of creating custom column types anywhere?
    s
    • 2
    • 3
  • e

    Evan R.

    09/03/2019, 5:06 PM
    Hey all, is the best way to return the value of a sum to create an aliased field and pass it into the query like so? Or can I just refer to the column in the
    .get()
    on the query via the
    .sum()
    method on the column? Here’s what I have right now:
    val sumAlias = TransactionsTable.amount.sum().alias("campaignTotal")
    TransactionsTable.slice(sumAlias)
        .select { TransactionsTable.campaignID eq campaignID }
        .limit(1)
        .firstOrNull()
        ?.get(sumAlias)
    s
    • 2
    • 3
  • c

    cincue

    09/04/2019, 2:30 PM
    Hi! Is there any way to simulate a select failure with DSL API during testing?
    e
    • 2
    • 11
  • s

    SrSouza

    09/12/2019, 12:01 PM
    Hi @tapacin the future we will be able to create your own ColumnType?
    t
    • 2
    • 7
  • j

    Jacob Richards

    09/15/2019, 10:21 PM
    is it possible to return the entire row you’ve just inserted with .insert? I know there’s insertAndGetId, but I want to return the entire row.
    s
    k
    t
    • 4
    • 3
  • k

    kushalp

    09/18/2019, 10:21 AM
    What migration tool are people using with Exposed?
    j
    e
    • 3
    • 2
  • p

    Philipp Mayer

    09/18/2019, 7:40 PM
    Hey guys, I'm quite new to exposed and pretty sure I'm missing something:
    override fun getColorByCompany(company: String): List<String> {
            val color = transaction { Companies
                    .slice(Companies.color)
                    .select { Companies.name eq company }
                    .map { it.toString() }
            }
           return color
        }
    How can I get a single string as result and not a list of strings? Or should I convert it afterwards for myself? Thanks in advance!
    e
    • 2
    • 2
  • b

    bitkid

    09/23/2019, 11:44 AM
    i am using now exposed for a few month and i have to say that this article in combination with the github repo was an eye opener 🙂 https://touk.pl/blog/2019/02/12/how-we-use-kotlin-with-exposed-at-touk/
    👍 1
    • 1
    • 2
  • a

    Alexander Weickmann

    09/23/2019, 1:26 PM
    Hi all, it should be possible to write data and then immediately read that data within the same transaction right? In our code, this works except for one special case, in which the data only shows after the transaction block completes. I don't fully understand the "Working with Coroutines" section in the wiki where it says: " If you want to use the result and execute another queries within the same transaction you can use andThen function."
    val launchResult = suspendedTransactionAsync(<http://Dispatchers.IO|Dispatchers.IO>, db = db) {
        FooTable.selectAll().count()
    }.andThen { count ->
        BarTable.select { BarTable.value eq count }.map { it[BarTable.name] }
    }
    here it seems that the result of the count is only available to the remaining code when passed via andThen function. when exactly is it necessary to use the andThen function? would this not work?
    val launchResult = suspendedTransactionAsync(<http://Dispatchers.IO|Dispatchers.IO>, db = db) {
        val count = FooTable.selectAll().count()
       BarTable.select { BarTable.value eq count }.map { it[BarTable.name] }
    }
    t
    • 2
    • 3
  • v

    Vinicius Araujo

    09/24/2019, 11:55 PM
    Hi everyone. Does anyone have implemented a dynamic field update. I mean, one function that update the given property with given value (maybe with generics) ?
    t
    s
    • 3
    • 11
  • j

    jfburdet

    10/01/2019, 3:35 PM
    Hi folks. I just found a bug i my exposed DAO code. The following code returned incorrect value (testing against object instance) collection member : val existingVote = this.votes.firstOrNull { vote -> vote.votedBy == voter } This was fixed by testing against id's : val existingVote = this.votes.firstOrNull { vote -> vote.votedBy.id == voter.id } Why can't I trust testing against object instance ? Shouldnt this be referenced somewhere in the documentation ? Why exposed library doesn't provide a comparison overload operator to compare two IntEntity object ? (this was tested with 0.17.4) Edit again : If i make my class inherit of this class below, this fix my problem ... open class MyIntEntity(id: EntityID<Int>) : IntEntity(id) { override fun equals(other: Any?): Boolean { if (other !is IntEntity) return false return other.id == this.id } } I believe this is because separate instance object have been created by two different transactions ... anyway, it should make sense to expect that such object are somehow the same because they have the same id's ? What do you thing ? Did I found a bug ? Where should I report it ? Last edit ( 😉 ) : I made a sample project to show-case the problem : https://gitlab.com/jfburdet/tstexposed/blob/master/test/kotlin/ComparisonTest.kt ... feel free to clone it and have a look
    t
    • 2
    • 2
  • t

    tjohnn

    10/02/2019, 1:24 PM
    Is there a column type that takes a
    Collection
    of
    String
    ? I am having issue with inserting data into postgresql array column Or do I to parse it to an acceptable format myself? I am getting this error:
    Caused by: org.postgresql.util.PSQLException: ERROR: column "images" is of type character varying[] but expression is of type character varying
    v
    • 2
    • 2
  • t

    tapac

    10/05/2019, 5:02 PM
    Exposed 0.17.4 released with critical fix related to transaction isolation. Please update.
    👍 2
    j
    • 2
    • 3
  • б

    Бежан Александр

    10/10/2019, 11:34 AM
    Hey guys. I need your help with suspended transactions. When I do:
    newSuspendedTransaction(<http://Dispatchers.IO|Dispatchers.IO>, database) {
        Ticket.all().count()
    }
    It fails with
    org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-199]
    Database is H2
    t
    • 2
    • 1
  • e

    Evan R.

    10/16/2019, 3:03 PM
    Just want to confirm something involving the experimental coroutine support via
    newSuspendedTransaction
    . The documentation states that we shouldn’t share a transaction between multiple threads due to undefined behavior, so are we not allowed to call other suspending functions within a
    newSuspendedTransaction()
    block given when the suspended transaction resumes it may resume on another thread? For example:
    newSuspendedTransaction(<http://Dispatchers.IO|Dispatchers.IO>) {
      val result1 = myTable.select { ... }.toList()
      // newSuspendedTransaction suspends here
      callSomeSuspendingFunction()
      // newSuspendedTransaction resumes, possibly in another thread??
      val result2 = myTable.select {...}.toList()
    }
    Or:
    newSuspendedTransaction(<http://Dispatchers.IO|Dispatchers.IO>) {
      coroutineScope {
        repeat(5) { 
          // Should I be using suspendedTransactionAsync here?
          launch { someFunctionThatUpdatesRows() }
        }
      }
    }
    t
    • 2
    • 2
  • s

    Szymon Lipiński

    10/16/2019, 5:08 PM
    Just a small remark. I'd really love to use this library. However, the lack of documentation to almost everything makes it really impossible. Function name is not enough to understand what I should use. Really. There are classes like Database where there is literally not a single line of documentation. Also the
    notForUpdate
    function is a mystery 🙂 I just hope that I get what it really does. Also, I think that if a column has a name like
    xx"yy
    then it would be escaped incorrectly, however, I have a small problem with tracking the code responsible for this.
    a
    • 2
    • 3
  • e

    Evan R.

    10/17/2019, 7:14 PM
    The fact that
    newSuspendedTransaction
    closes the current transaction at the end of the block is creating a real headache for me. I have suspend functions which will start a new suspended transaction on the IO dispatcher, but they cannot call other suspend functions doing the same thing. Is there a way around this that I’m not seeing? My current workaround is to make separate, private suspending functions which are exposed publicly via a
    newSuspendedTransaction
    block.
    Untitled
    👀 1
    t
    m
    • 3
    • 3
  • m

    maxmello

    10/24/2019, 9:18 AM
    Inside a Ktor post { … } I have the following code:
    val dao = newSuspendedTransaction { MyDAO.findByValueOrThrowException(value) }
    
    // MyDAO companion (LongEntityClass)
     suspend fun findByValueOrThrowException(value: String): MyDAO {
            return withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
                    find { MyTable.value eq value }.firstOrNull() ?: throw RuntimeException("MyDAO not found")
          }
    }
    10 seconds after the exception is thrown, I get the following log message: com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@5b4d25e7 on thread DefaultDispatcher-worker-1, stack trace follows: java.lang.Exception: Apparent connection leak detected As you can see, I am using Hikari for a thread pool (config.leakDetectionThreshold = 10000L, corresponding to the 10 seconds after the message appears) So am I not allowed to throw an exception and catch it outside the transaction context, or am I doing something else wrong? (I am using Postgres)
    s
    e
    • 3
    • 13
  • v

    Vinicius Araujo

    10/26/2019, 11:39 PM
    Hi! Is there a way to use DSL to insert and query with one-to-many child list as easy as the DAO espec (eg. all in one statment)?
    t
    • 2
    • 1
  • e

    Egor Babarykin

    10/29/2019, 11:33 AM
    Hi! Can anyone help me with eager loading of referrers entity I make this requests
    SomeEntity.all()
                    .with(SometEntity::users)
                    .toList()
    This command makes sql query to db for select SometEntity from SomeTable and SomeUserEntity from SomeUserTable But when i'm calling get of SometEntity.users it makes another query to db to select SomeUserEntity only for one SomeEntity
    t
    • 2
    • 2
  • m

    magisu

    11/01/2019, 6:26 PM
    Hi, pretty new to exposed, a quick question -- can I put
    dbConnect = Database.Companion.connect()
    in my SpringBoot
    PostConstruct
    function of service, and keep using it forever? Will it timeout or get expired?
    t
    • 2
    • 2
  • t

    tapac

    11/05/2019, 2:05 PM
    Exposed 0.17.7 was released. I hope it was the latest bugfix release in that branch as new 0.18.1 almost ready and tested (with new multiple modules and java8 time support). The whole list of bug fixes and features is here https://github.com/JetBrains/Exposed/blob/0.17.4/ChangeLog.md#0177
    👏 2
    e
    • 2
    • 2
  • j

    Jorge R

    11/11/2019, 1:54 PM
    ey guys, I’m trying to define a clean arch for testing in my Ktor + Exposed + Hikari project. Do you know if there is any good approach for unit testing those methods that define a transaction?
    j
    • 2
    • 9
  • t

    tapac

    11/16/2019, 5:27 PM
    Hello everyone! Exposed 0.18.1 is finally here! It is huge release which includes Java Time API support and (as a side effect) new modules system. In the future it will allow to support diffrent async drivers and dialect specific extentions. Please read https://github.com/JetBrains/Exposed/wiki/LibDocumentation#exposed-0181-and-higher to know about new modules. I was trying to make as less broken changes as possible but I advice to read https://github.com/JetBrains/Exposed/wiki/Migration-Guide before moving to 0.18.1. If you find what some cases is missing please DM me to update documentation. For some time I will support both 0.18.x and 0.17.x versions, but only critical fixes will be backported to 0.17.x branch. Please report any problems with 0.18.1 here or on github issue tracker.
    👍 1
    🎉 8
    b
    a
    • 3
    • 6
  • b

    Brian Carbone

    11/20/2019, 4:10 PM
    just the fact that opt is nullable?
    t
    • 2
    • 1
  • d

    doyaaaaaaken

    11/22/2019, 11:38 AM
    Hi, does anyone know about this problem’s solution? https://stackoverflow.com/questions/58993409/how-to-avoid-n1-query-problem-on-kotlin-exposed-when-getting-value-by-daos-r I met N+1 query problem and I’d like to know about correct solution. Thank you.
    t
    • 2
    • 2
  • a

    Andrew Kirkham

    11/22/2019, 4:11 PM
    hi all. is there a way using the exposed DSL to cache results from a select transaction
    t
    • 2
    • 3
  • b

    Brian Carbone

    11/22/2019, 8:25 PM
    how do you make a unique varchar column without indexing
    t
    • 2
    • 1
Powered by Linen
Title
b

Brian Carbone

11/22/2019, 8:25 PM
how do you make a unique varchar column without indexing
t

tapac

11/22/2019, 9:44 PM
Afaik unique constraint and unique index are almost the same as constraint creates an index to check uniqueness
View count: 14