zio-quill
zio-quill copied to clipboard
Code generation in subquery does not translate table name correctly
Hi,
I have this (simplified) piece of code including a subquery:
ctx.run {
query[BinaryFile]
.filter(binaryFile => query[BinaryFile].filter(_.id == binaryFile.id).isEmpty)
.delete
}
I get this SQL: DELETE FROM binary_file WHERE NOT EXISTS (SELECT x1.* FROM binary_file x1 WHERE x1.id = binaryFile.id) where the last binaryFile (in binaryFile.id) should be (binary_file) as my table's name is binary_file. If I change my variable name binaryFile in filter to binary_file it works, so quill seems to not transform my code's variable name.
This example is of course artificial but I hope it's a minimal example for my problem.
Version: 3.6.0-RC3 Module: quill-jdbc and quill-jasync-postgres Database: PostgreSQL
Expected behavior
The naming strategy should be respected in the subquery.
Actual behavior
The naming strategy is not respected in the subquery.
Steps to reproduce the behavior
I created this scastie to reproduce the problem: https://scastie.scala-lang.org/uy6vJ6XJQMeiN1c0psVgAg
Workaround
A workaround is to rename the variable to match the database name (binary_file instead of binaryFile in this case).
@getquill/maintainers
I have encounter the same issue for 3.5.1/postgres
Still in 3.7.0 :-|
Is there any chance to get this fixed? 🙏 Would be nice to know if it's not getting fixed because Scala 3 has a higher priority or if it's just not easy to fix.