zio / zio-quill

Compile-time Language Integrated Queries for Scala

Home Page:https://zio.dev/zio-quill

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQL Query Generation Error: Unquoted Keywords Causes Statement Errors with Postgres

fabianhjr-dealengine opened this issue · comments

Version: 4.6.1
Module: quill-sql
Database: postgres

Expected behavior

Generated query works

Actual behavior

user is inserted as is without quotes which causes an error due to being a keyword in postgres

Steps to reproduce the behavior

case class User(id: Int, username: String, email: String)
case class Post(id: Int, title: String, content: String, userId: Int)

for {
  user <- query[User]
  if user.email == lift(email)
  post <- query[Post]
  if post.userId = user.id
} yield post

Should produce a query with user quoted as "user" but leaves it unquoted.

Workaround

Not using reserved keywords as var names (neither in fors, nor filters nor joins)

@getquill/maintainers