Hey! I've spent half an evening experimenting with...
# squarelibraries
e
Hey! I've spent half an evening experimenting with SQLDelight using Postgres for JVM. So far the developer experience has been pretty bad, and I'm wondering if it's just my lacking skills, lacking docs or overall lack of functionality that's the culprit. I'm using IntelliJ with the latest SQLDelight plugin. My biggest issue has been that schema/query code generation silently fails. Is there any way to get it to output some errors/warnings into some console when that goes wrong?
I'm also confused on how to place migrations in relation to queries. It seems to be processing files alphabetically? I think that with "Fresh schema" approach, one would simply place tables and their related queries in a single
.sq
file. But now I'd like to have
v1__schema.sqm
,
v1.2__add_some_columns_and_tables.sqm
, along with queries in
HockeyPlayer.sq
(to get
Database.hockeyPlayerQueries
generated). Are there any conventions in this area?
h
The migration uses numbers, but sub versions aren’t supported, only 1 -> 2 etc.
Code gen should not fail without any errors. Do you have a sample/can create an issue?
e
but the
v
-prefix is supported? 🙂 Sure, lemme see if I can repro it in a small sample.. Is there any "magic" happening when using the SQLDelight IJ Plugin that triggers codegen when saving
.sq(m)
files? Where would the errors normally be reported?
h
Yes, sqldelight expects 1 and only 1 number in the file name, it doesn’t matter where.
âś… 1
Okay, when using the IntelliJ plugin, I think it should be reported in the top bar indicating there was a failure. But error reporting is way better when using the Gradle plugin, just call the Gradle task.
e
Okay, I think the issue is mainly that I don't see the bar you're referring to when the IJ plugin runs codegen. Do you mean something similar to this one, shown in the top of the editor when syncing gradle?
Running the gradle task shows a very informative error message
I had some trouble figuring out the name of the task (running
./gradlew tasks
was broken due to another plugin having issues). Maybe adding to docs somewhere, similar to the SQLite (Android) docs would be helpful to new users?
Copy code
The Database class is generated by the generateSqlDelightInterface Gradle task which is run automatically by the SQLDelight IDE plugin when you edit a .sq file, and also as part of a normal Gradle build.
n
intellij idea has a sidebar with gradle tasks.. that helps a lot