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

Column aliases don't use NamingStrategy #2340

Open
vladimirkl opened this issue Dec 8, 2021 · 3 comments
Open

Column aliases don't use NamingStrategy #2340

vladimirkl opened this issue Dec 8, 2021 · 3 comments

Comments

@vladimirkl
Copy link
Contributor

vladimirkl commented Dec 8, 2021

Version: 3.12.0
Module: quill-jdbc-zio
Database: postgres

Expected behavior

A fix for #2328 should use context NamingStrategy for column aliases

Actual behavior

When using SnakeCase for quill context column aliases are generated with default CamelCase

case class Person(personName: String, age: Int)

val q1 = quote {
  (query[Person].map(p => Person("x", p.age)) union query[Person]).map(_.personName)
}

val q2 = quote {
  infix"INSERT into names $q1".as[Insert[Person]]
}

q1 will print SELECT x1.personName FROM ((SELECT 'x' AS personName FROM person p) UNION (SELECT x.person_name AS personName FROM person x)) AS x1

q2 will print INSERT into names SELECT x1.personName FROM ((SELECT 'x' AS personName, p.age FROM person p) UNION (SELECT x.person_name AS personName, x.age FROM person x)) AS x1

In both cases person_name must be generated everywhere.

This breaks existing queries which use infix and rely on column names

https://scastie.scala-lang.org/vladimirkl/r8zPuvwRSzWmh0NBIC3s2Q/9

Workaround

Downgrade to 3.10.0

@getquill/maintainers

@deusaquilus
Copy link
Collaborator

Shoot, looks like a sub-expansion issue. Will try to address this ASAP.

@vladimirkl
Copy link
Contributor Author

@deusaquilus is it possible to have a fix for this issue in close future? It blocks migration to 3.12.0 for me

@deusaquilus
Copy link
Collaborator

deusaquilus commented Jan 16, 2022

@vladimirkl I experimented with this in a few different branches and the issue is deeper then I thought. I'm going to introduce a switch that will allow you to disable the column expansion entirely (i.e. the way it was in 3.10.0) in order unblock you. I.e. add the following to your SBT opts or your JVM opts in SBT if you are forking for Compile:

-Dquill.query.subexpand=false

Continuing working on a solution in #2387.

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

2 participants