Hey! I'm currently having an issue with SQLDelight...
# squarelibraries
t
Hey! I'm currently having an issue with SQLDelight using the
RETURNING *
syntax because of the autogen.
Copy code
sqldelight {
    databases {
        create("Database") {
            packageName.set("com.test")
            deriveSchemaFromMigrations = true

            dialect("app.cash.sqldelight:postgresql-dialect:2.0.1")
        }
    }
}
I define my table creations in the
migrations
folder so as time goes on I just run all the migrations to get my table and then I define all my queries in the standard
com.test
path. The problem comes when I try to do something like
Copy code
testQuery:
UPDATE SET Test WHERE id = :id RETURNING *
In the autogenerated code it fails to resolve the class
Test
because that data class is being generated in the
migrations
folder instead of
com.test
. Is there any way to fix this issue?
After a little bit of testing this is some weird behavior I found.
Copy code
getAll:
SELECT * FROM Test;
Will automatically resolve the class by doing
migrations.Test
as the return in the Kotlin generated code. But using
RETURNING *
doesn't mimic this.
g
Try with current snapshot:
2.1.0-SNAPSHOT
Issue: https://github.com/cashapp/sqldelight/issues/4448 was fixed in current snapshot after
2.0.1
was released Configure build for using snapshot: https://cashapp.github.io/sqldelight/2.0.1/#snapshots
t
Yep that seems to have fixed it, would using
2.1.0-SNAPSHOT
be stable in production though?
g
If you are happy enough with using
2.0.1
in production, then the snapshot should be ok too Also, there are some more fixes for PostgreSql Dialect in the snapshot - see https://github.com/griffio/sqldelight-postgres-01 I don’t know when the next version of SqlDelight will be released as that would be the current snapshot anyway
t
Perfect, thank you for your help! Also by chance is there a list of changes for the snapshot? I’d love to learn all the new stuff I’m getting with it