Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic queries do not respect decoders of embedded classes #2680

Open
lpld opened this issue Jan 9, 2023 · 0 comments
Open

Dynamic queries do not respect decoders of embedded classes #2680

lpld opened this issue Jan 9, 2023 · 0 comments

Comments

@lpld
Copy link

lpld commented Jan 9, 2023

It looks like #2607 breaks SQL generation in dynamic queries, because now dynamic queries ignore any decoders defined for embedded classes.

Version: 4.6.0
Module: quill-sql, quill-jdbc

Here is a simple example:

import io.getquill._
val ctx = new SqlMirrorContext(PostgresDialect, SnakeCase)
import ctx._

// embedded class with custom decoder
case class PersonName(firstName: String, lastName: String)
implicit val pNameDecode = MappedEncoding[String, PersonName] { PersonName(_, "Smith") }

// top-level class
case class Person(id: Long, name: PersonName)

Expected behavior

Both query[Person] and dynamicQuery[Person] generate identical SQL.

Actual behavior

println(run { query[Person] }.string)
// correct, Quill respects the decoder
// SELECT x.id, x.name FROM person x

println(run { dynamicQuery[Person] }.string)
// incorrect, Quill includes the fields of the embedded class, ignoring the defined decoder
// SELECT x.id, x.first_name AS firstName, x.last_name AS lastName FROM person x

Steps to reproduce the behavior

Scastie snippet: https://scastie.scala-lang.org/UqW82jVTQuuyNR2McIKnzA
Unfortunately, I couldn't make Scastie work with dynamic queries (some strange class loader error in runtime), so, in case it helps, here's a simple github project that shows the same issue: https://github.com/lpld/quill-embedded-bug/blob/master/src/main/scala/example/Hello.scala

Workaround

No workaround that I could find.

@getquill/maintainers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant