zio-quill icon indicating copy to clipboard operation
zio-quill copied to clipboard

Code generation in subquery does not translate table name correctly

Open ocordsen opened this issue 4 years ago • 3 comments

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

ocordsen avatar Jan 06 '21 15:01 ocordsen

I have encounter the same issue for 3.5.1/postgres

otrebski avatar Jan 21 '21 19:01 otrebski

Still in 3.7.0 :-|

danslapman avatar Apr 07 '21 09:04 danslapman

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.

ocordsen avatar Oct 06 '21 08:10 ocordsen