:boom: ExoQuery 2.0.0 is out! ExoQuery started as...
# feed
a
💥 ExoQuery 2.0.0 is out! ExoQuery started as “what if we could treat SQL as a real part of Kotlin, not just a clunky DSL or a string we pray over.” 2.0.0 is the first release where that really feels complete to me. Headline features: ‣ Implicit JSON dereferencing You'll never want to use
->
and
->>
operators again! Use regular property dereferencing to access JSON properties of objects.
Copy code
@SqlJsonValue @Serializable 
data class ContactInfo(val email: String, val phone: String)
@Serializable 
data class User(val id: Int, val name: String, val contacts: ContactInfo)

val emails = sql {
    Table<User>().map { it.contacts.email }
}
// Postgres:   SELECT contacts ->> 'email'         FROM ...
// SQL Server: SELECT JSON_VALUE(contacts, '$.email') FROM ...
I wrote a blog post about this feature with runnable code samples. Read it here. ‣ R2DBC support Works for Postgres, MySQL, SQL Server, and H2 Simpler SQL DSL: •
capture { … }
is now just
sql { … }
, which is what it always wanted to be. •
CapturedFunction
/
CapturedDynamic
were renamed to
SqlFragment
/
SqlDynamic
to match what they actually are. • More built-in SQL helpers: common functions,
IN (subquery)
support,
stringColumn.contains(string)
and better null-handling. • A batch of performance work (fewer unnecessary materializations) and a pile of bugfixes around error reporting and edge cases. If you’ve been waiting for “the version where I can actually put this in production and not feel weird about it,” this is the one.
👀 5
👍 4
K 7
🚀 2
r
Can I try using ExoQuery with Kotlin 2.3.0-RC ?
a
Not yet. Give me a week and I'll release a version
r
It's based on the compiler plugin and I always need a matching Kotlin version, right?
a
Yes... but I'm working on a mitigation of that too
👍 1
s
really feels complete to me
The GitHub page is saying "JS-coming soon" 👀
I like how exhaustive the GitHub readme is with all the samples. Very nice.
a
The GitHub page is saying "JS-coming soon" 👀
People are actually using Kotlin JS with sqlite these days? I haven't prioritized it yet but maybe I should 😅
I like how exhaustive the GitHub readme is with all the samples. Very nice.
Thanks! I've got a bunch of runnable code samples at exoquery.com/examples
s
> People are actually using Kotlin JS with sqlite these days? People can't, because it's not available. A few weeks ago I wanted to use it for my ONI seed browser, but since the support was missing, I ended up implementing the search query directly in Kotlin.
a
I'm glad to hear people are actually using Kotlin for JS frontends! I'll work on it soon.
👍 1
s
All my web apps are Compose for Web, so using Kotlin/WASM.
👌 1
plus1 1
https://github.com/stefanoltmann/oni-seed-browser is the project I wanted to use SQLite in browser with. I settled now with another solution and it's unlikely that I'll change that again, but I think there should be good options to use SQLite in browser. 🙂
a
Where's the SQLite stuff? I want to have a look
s
Doesn't exist anymore. It was in a now-deleted branch.
Thanks for your offer. 🙂
The backend https://github.com/stefanoltmann/oni-seed-browser-backend uses Exposed now for the SQLite database and packages that to a Protobuf object. The client works with that. If a SQLite solution would have been available at that time the client would have been working on the database directly (only reading in that case). Exposed is unfortunately Desktop-only, not multiplatform.
a
Yeah, I know. Very hard to build ORMs without reflection
👍 1
s
I could imagine having future Desktop projects that work on SQLite porting to Compose for Web and continue using SQLite. We just lack a proper lib for that.
> Very hard to build ORMs without reflection Interesting insight. I actually wondered what the reason is that JS is seldom supported.
The ExoQuery syntax/API makes a lot more sense to me than Exposed. I always forget how to use it and need to look up the docs.
a
Thanks! I've been refining this design for many years.
s
For my next project I'll give it a try. 🙂
a
Great! If you've get any issues at all please let me know.
👍 1
w
I was also interested because I have some really complex filtering queries on web, but didn't look too far into it since I wasn't sure what JS support meant. Naively it seems like I could manually replace the driver to point to the Worker I'm currently using for SQLDelight as long as it exposed the raw SQL.
s
If I remember correctly there was a good and a bad way to do it... One involved loading the complete sqlite into RAM and was inefficient. I don't quite remember what the proper, harder way was to do it.
r
@Alexander Ioffe I've noticed you are referring to the deprecated
io.r2dbc:r2dbc-postgresql
driver in the readme. The quickstart chapter on the website uses the correct
org.postgresql:r2dbc-postgresql
driver.
a
I update the readme to the right driver. Thanks!
n
Hi, looks very promising. Any plans to also support e.g. Spanner or Oracle?
a
Oracle support is coming soon. For spanner, you can use the ExoQuery postgres dialect together with the Google Spanner JDBC driver (here). Can make a code sample if you'd like.
n
Yes, sample would be nice, if it is not too much work.
d
I'm currently using jasync (which unfortunately stopped development) so I was looking wor something else. I was using Exposed befor so I gave that another look, but as long as their non-blocking part is not finally realeased (it's currently in 1.0.0-rc4) I was basically just waiting. Now I see your library. I will definitly try to use it, since it seems to support that right out of the box. 👍
a
@Norbert Kiesel As far as I'm seeing, the spanner dialect looks like it's just a combo of standard casting, ANSI Json, and zone-aware TIMESTAMP. I can put together a GoogleSQL dialect fairly easily. Meanwhile I'll put together a sample using the Postgres dialect.
n
Sounds great! I will try using your code with Spanner early next year.