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

Running an invalid query can throw an IllegalStateException #295

Open
mattdavpir opened this issue Jul 7, 2023 · 0 comments
Open

Running an invalid query can throw an IllegalStateException #295

mattdavpir opened this issue Jul 7, 2023 · 0 comments

Comments

@mattdavpir
Copy link

Version: 4.6.0.1
Module: quill-jdbc-zio
Database: Postgres

Expected behavior

An error when validating a query provided to the run method would return a failed ZIO.

Actual behavior

The method throws an IllegalStateException.

Steps to reproduce the behavior

case class MyTable(stringField: String, intField: Int)

ZIO.serviceWithZIO[Postgres[SnakeCase]] { postgres =>
  // Should be `_.stringField == lift(string)`
  val selectQuery = quote(query[MyTable].filter(_.stringField == string).value)
  postgres.run(selectQuery)
}.tapErrorCause(e => ZIO.logErrorCause("Oh no!", e))

Because an exception is being thrown the error logging is bypassed.

Workaround

Declaring the query as an inline def allows this particular mistake to be picked up at compile time (but I would think this would still be an issue for any dynamic queries that couldn't be checked during compilation).

@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