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

Missing column alias for static union query used in infix #2328

Closed
vladimirkl opened this issue Nov 30, 2021 · 1 comment · Fixed by #2335
Closed

Missing column alias for static union query used in infix #2328

vladimirkl opened this issue Nov 30, 2021 · 1 comment · Fixed by #2335

Comments

@vladimirkl
Copy link
Contributor

Version: 3.11.0
Module: quill-jdbc-zio
Database: postgresql

Expected behavior

Static query with union should look the same including column aliases when used standalone or when used as a part of infix

Actual behavior

Column aliases are missing when query with union used in infix expression

Steps to reproduce the behavior

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

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

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

q2 will print INSERT into names SELECT x1.name FROM ((SELECT 'x', p.age FROM person p) UNION (SELECT x.* FROM person x)) AS x1 - which is error in Postgres with message org.postgresql.util.PSQLException: ERROR: column x1.name does not exist. Running just q1 returns correct results.

https://scastie.scala-lang.org/vladimirkl/bkhEuyRiQqyFCW14oe0ipA/10

Workaround

add column alias manually using infix

@getquill/maintainers

@deusaquilus
Copy link
Collaborator

Thanks for this reproduction! This looks very fixable with Quats info.

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

Successfully merging a pull request may close this issue.

2 participants