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

    rcd27

    07/05/2021, 5:17 PM
    Is there any way to execute custom "plain" statements via
    Exposed
    ? Or should I just use plain old Java interface for that? I have these one: (just trying to implement full-text-search in postgres)
    b
    • 2
    • 4
  • a

    Antonio Acuña Prieto

    07/11/2021, 6:20 PM
    Do I need to create a mapper fun to transform ResultRow to the class I want? Something like: Articles.select { Articles.id eq I’d }.map { toArticle(it) }.single()
    e
    • 2
    • 1
  • d

    Damien

    07/12/2021, 4:45 PM
    Hi, how can I reference aliased columns from a subquery and use within a top-level function.. e.g. (greatly simplified for illustrative purposes)
    select sum(subQuery.myCol + subQuery.myCol) from (select col as myCol) subQuery
    I have my subselect working, have my column alias working, I can select by the alias (e.g.
    select subQuery.myCol from (select...)
    ). But I cannot figure out how to construct further functions from the aliased columns. I essentially have multiple aliased columns in a subselect and I wish to multiply them in some way and query the result. Appreciate any insight! No idea where to start (QueryBuilder?)
    • 1
    • 1
  • a

    Ali Olfat

    07/13/2021, 9:51 PM
    I have four tables all with 5 common columns. Is there a way to extract out the common columns into their own class as part of the DSL? Is that what CompositeColumn is for?
    • 1
    • 1
  • j

    Jgafner

    07/14/2021, 12:01 PM
    Hi probably a dummy question and I am missing something - how do I translate this query in the code:
    select *
    from regression_notifications rn
             join notification_checks nc on rn.id = nc.regression_id
             join check_issues ci on nc.id = ci.check_id
    where ci.status = "Open"
    I tried:
    RegressionTable.join(CheckTable.join( IssueTable,JoinType.INNER),JoinType.INNER).select { IssueTable.status eq "Open" }
    but it return different results thanks
    b
    • 2
    • 1
  • a

    Austin Paquette

    07/17/2021, 2:44 PM
    Hey, there's an issue on this already but no response (and nothing on the roadmap) about the ability to have a many-to-many reference setup where the junction table needs an additional attribute, I cannot find anyone else that has tried and succeeded. I'm not quite dangerous enough with Kotlin (yet?) to implement such a feature myself so I was hoping to get some guidance on some options. 🧵
    • 1
    • 1
  • n

    Nayeem Zen

    08/09/2021, 6:19 PM
    Also is there any planning of doing codegen similar to jooq to generate the tables/entities from the database? We were considering using Flyway for migrations so redefining tables structure entities in sql and again in kotlin code would lead to some duplicated source of truth
    👍 1
    b
    a
    • 3
    • 5
  • t

    Trevor Merritt

    08/17/2021, 11:52 AM
    Anyone know of a library like Ruby's 'papertrail' for Exposed? I'm subclassing the IntIdTable to add before and after hooks, but if someone else has already done it, no need to reinvent the wheel. 🙂
    h
    • 2
    • 2
  • t

    TwoClocks

    08/17/2021, 9:14 PM
    do read-only queries need to be done in a transaction as well?
    ł
    • 2
    • 1
  • l

    Lbenyehu

    08/18/2021, 12:39 PM
    Hi guys! I didn’t find any explanation how to create a table (postgres in my case) with partitions… someone know??
    r
    • 2
    • 7
  • c

    codec

    08/22/2021, 3:54 AM
    why does running jars from the command line with kotlin not include the standard java libraries?
    c
    ł
    s
    • 4
    • 7
  • a

    Alex

    08/26/2021, 2:35 PM
    Hi! Is anybody aware of whether Kotlin’s value (inline) classes are supported?
    t
    • 2
    • 1
  • d

    Das135

    09/02/2021, 9:24 AM
    Hey guys! Please, does Exposed provide any mechanism how to "intercept" query executions before I call database? My use-case is to store all database operations that were executed. We have Exposed code spreaded on multiple places in code, so it would be perfect to handle this functionality on one place instead of writing some methods to all
    transaction {}
    blocks. It is possible? Thank you!
    t
    • 2
    • 2
  • h

    hfhbd

    09/07/2021, 2:19 PM
    Hey, how would you write this query in Exposed?
    select name, min(time), max(time) from data group by name
    In https://github.com/JetBrains/Exposed/wiki/DSL#group-by there is no good sample
    b
    • 2
    • 2
  • m

    MrPowerGamerBR

    09/12/2021, 3:37 AM
    How can you create a table that has two unique constraints? I've found this issue: https://github.com/JetBrains/Exposed/issues/239 And after updating the code to the newer Exposed version... it works on PostgreSQL (yay!) but it fails on SQLite with the following error:
    Exception in thread "main" org.jetbrains.exposed.exceptions.UnsupportedByDialectException: Auto-increment could be applied only to primary key column, dialect: sqlite.
    Here's the table:
    object Abc : LongIdTable() {
        val user = long("user")
        val user2 = long("user2")
    
        override val primaryKey = PrimaryKey(id, user, user2)
    }
    So... is that an Exposed issue? Because I have no idea why it thinks it is a auto increment column. The only auto increment column is the "id" but it is also being included as a PrimaryKey
    a
    • 2
    • 3
  • d

    dave08

    09/13/2021, 11:37 AM
    How do I cast a json field to a string in exposed DSL (using postgres db)?
    b
    t
    • 3
    • 11
  • i

    IsaacMart

    09/14/2021, 3:40 AM
    Hello all, I have a model in my android project that has a type converter of a custom class. My android project has a backend built on ktor. The ktor project also has a similar model and am using postress database for storage. The problem that i am facing is storing the type converted class inside my postgress alongside other attributes. Here is the models of the two. Thanks in advance. Android model
    @Entity(tableName = "requests")
    public class Request extends BaseObservable implements Parcelable {
        @PrimaryKey(autoGenerate = true)
        private int request_id;// Document_id
    
        private String r_clients_id;
        private int r_tasker_id;
        private User user;// Type converter 
        private String requested_skill;
        private String time_stamp;
    }
    Same model for my ktor project
    class Request(
        val request_id: Int,
    
        val r_clients_id: Int,
        val r_tasker_id: Int,
        val user: User,
        val requested_skill: String,
        val time_stamp: String,
        val arrival_date: String,
    ): Serializable, Principal
    Here is where am facing the challenge. I really don't know how to insert or reference the Type converter class in my object class.I am new to ktor and exposed.
    object Requests : Table() {
        val requestId: Column<Int> = integer("request_id").autoIncrement().primaryKey()
        val rClientId: Column<Int> = integer("r_clients_id").references(Users.userId)
        val rTaskerId: Column<Int> = integer("r_tasker_id").references(Taskers.taskerId)
        val user: Column<User> = ?????????????????????????
    
        val requestedSkill = varchar("requested_skill", 128)
        val timeStamp = varchar("time_stamp", 64)
        val arrivalDate = varchar("arrival_date", 64)
    }
    😇 2
    t
    • 2
    • 6
  • e

    edwinRNDR

    09/14/2021, 10:17 AM
    Hi, I suspect that what I am doing with Exposed (0.31) is leaking memory and/or resources. Are there ways to disable all of Exposed's caching? What are tools to detect improper use of the Exposed DAO?
    b
    t
    • 3
    • 17
  • b

    BorzdeG

    09/16/2021, 6:13 AM
    Is it possible to validate all Table objects against the database schema when starting the service?
    t
    • 2
    • 2
  • e

    Endre Deak

    09/22/2021, 7:29 PM
    does Exposed uses reflection only for DAO mode, or there is reflection usage in DSL as well?
    t
    • 2
    • 4
  • n

    nullium21

    09/27/2021, 4:33 PM
    how do i do one-to-many? i have an entity like this:
    class LogChannel(id: EntityID<Long>): LongEntity(id) {
        companion object : LongEntityClass<LogChannel>(LogChannels)
        val guild by GuildConfig referencedOn LogChannels.guild
    }
    
    object LogChannels: LongIdTable() {
        val guild = reference("guild", GuildConfigs)
    }
    and an empty
    GuildConfig
    entity +
    GuildConfigs
    table how can i have the
    GuildConfig
    have a list of all `LogChannel`s that point to it? i've tried this:
    val foos by LogChannel via LogChannels
    but it says "`Table does not reference target`"
    ł
    • 2
    • 1
  • d

    dave08

    09/29/2021, 10:09 AM
    Wondering if the new
    KotlinInstantColumnType
    can handle an int field that stores a unix timestamp?
    t
    • 2
    • 9
  • d

    dave08

    09/29/2021, 10:15 AM
    It seems like not, but it would be good that if the type is an
    Int
    , it should use
    Instant.fromEpochSeconds
    to convert it...
    h
    • 2
    • 2
  • d

    dave08

    09/30/2021, 11:32 AM
    Trying to figure out why
    Schema.create
    only creates my tables once when running h2 in memory dbs in my tests, I need to recreate the connection and tables for each test, but it doesn't do it after the first time... and then all the following tests fail...
    r
    e
    • 3
    • 6
  • ł

    Łukasz Bednarczyk

    09/30/2021, 12:22 PM
    Do you know when implementation of JSON column will be available?
    e
    • 2
    • 4
  • j

    joseph_ivie

    10/05/2021, 9:32 PM
    Taking API feedback for an extension library on Exposed: https://github.com/lightningkite/exposed-plus
    e
    • 2
    • 2
  • a

    Amaan

    10/08/2021, 2:02 PM
    I'm trying to use Kotlin Exposed on Jetbrains Compose for Desktop, but I keep getting an error when I try to reference a many to one relationship outside of the transaction. Essentially, I have an Event class and a Section class. Events have multiple sections. When I get an event via the transaction and then try to access the sections variable, I get a null pointer exception. I've attached my code below as well as the error message I got. I can't create composables inside of transaction functions which is why I have to get the list of events out of the transactions scope.
    Error_txt.txtMain_kt.cpp
    t
    r
    b
    • 4
    • 12
  • j

    John Pali

    10/15/2021, 3:28 PM
    I was wondering about a feature in Ktor/Exposed 🙂 Assume i got a table
    ID | User | value
    1  |  1   | value1
    2  |  1   | value2
    3  |  2   | value3
    In other ORM frameworks, if I want to extract only values from user=1, I could create a DB session and use 
    Values.all()
     and it'll fetch only [value1, value2] I don't want to fetch via 
    Values.select { Values.user eq user }
    🤦‍♂️ 1
    b
    d
    • 3
    • 7
  • b

    Bert Heyman

    10/21/2021, 9:40 AM
    Hey all! New to this space 🙂 I’m learning Kotlin with a PHP / Laravel background. Covered the basics and these make sense. As a next step, I’m looking into Ktor and Exposed. This tutorial helped me with Ktor: https://ktor.io/docs/creating-http-apis.html Next step would be to include Exposed in there as well, using their getting started: https://github.com/JetBrains/Exposed/wiki/Getting-Started#download Coming from a different background, I feel I miss some background on the installation process and frameworks so feeling a little lost there. It’s hard to assess resources I found, as they refer to different Kotlin/Ktor versions and I’m not so sure what’s still up to date (enough) and what is not. Any tips on what I could read into to get a better grasp? TL;DR: how can I properly install Exposed in Ktor?
    t
    r
    • 3
    • 3
  • n

    nilTheDev

    10/21/2021, 4:31 PM
    Okay here is my short experience with Exposed. I was thinking of developing a REST api with ktor. Ktor's documentations are awesome. It took me little time to get started. Connecting to a database is also a crucial part for developing an api. A quick search landed me on the Exposed page. There were nothing but a bunch of code in the README file. I understand Exposed has not even reached version 1, so I am not blaming it. All experience in regard to database connection I had was just using the sqlite library in python and executing bare sql queries. I was blown up with all the new terms like ORM, DAO, Hikari and so on. Tutorials wasn't helpful either. I was frustrated and overwhelmed. Then I tried to find what people use with Java. A name Hibernate popped out. I went on the docs. And fortunately it pointed me to a great article that pointed me to another one. Now, finally I am getting it. The bare SQL version for the JVM world is JDBC. And there are stable libraries other than exposed. Like JPA, Hibernate, JOOQ. I am finally able to connect to my database and run sql queries (using JDBC though 😅). I would look into some lightweight stable libraries other than Exposed as of now. Once I get comfortable with accessing databases, only then I would look into Exposed. This database thing became an ugly nightmare to me. Finally I will be sleeping peacefully tonight. 🙃
    m
    • 2
    • 3
Powered by Linen
Title
n

nilTheDev

10/21/2021, 4:31 PM
Okay here is my short experience with Exposed. I was thinking of developing a REST api with ktor. Ktor's documentations are awesome. It took me little time to get started. Connecting to a database is also a crucial part for developing an api. A quick search landed me on the Exposed page. There were nothing but a bunch of code in the README file. I understand Exposed has not even reached version 1, so I am not blaming it. All experience in regard to database connection I had was just using the sqlite library in python and executing bare sql queries. I was blown up with all the new terms like ORM, DAO, Hikari and so on. Tutorials wasn't helpful either. I was frustrated and overwhelmed. Then I tried to find what people use with Java. A name Hibernate popped out. I went on the docs. And fortunately it pointed me to a great article that pointed me to another one. Now, finally I am getting it. The bare SQL version for the JVM world is JDBC. And there are stable libraries other than exposed. Like JPA, Hibernate, JOOQ. I am finally able to connect to my database and run sql queries (using JDBC though 😅). I would look into some lightweight stable libraries other than Exposed as of now. Once I get comfortable with accessing databases, only then I would look into Exposed. This database thing became an ugly nightmare to me. Finally I will be sleeping peacefully tonight. 🙃
m

maxmello

10/22/2021, 8:49 AM
There is additional documentation in the wiki for Exposed: https://github.com/JetBrains/Exposed/wiki
n

nilTheDev

10/22/2021, 9:04 AM
I saw that. But because of the lack of basic JDBC skills I was struggling to make the connection with my database.
m

maxmello

10/22/2021, 9:33 AM
Ah okay, just wanted to make sure. I think the use case for Exposed and other libraries really only starts once someone has basic to medium understanding of SQL itself and then some in using plain queries as they are shown in the first link you posted. Using something like Exposed, where a SQL queries are “hidden” behind Kotlin functions, a table can be defined through a class etc. adds additional abstraction which is nice once you know how to use it, but in your case, Exposed might just not be the right tool (yet). I wouldn’t say that is because Exposed is not 1.0 yet, but because it is by design an abstraction layer above SQL that is only useful if you understand the lower level first.
View count: 11