Repository navigation
Reject nested lift at compile time and run nothing for empty batches - #818
Merged
Merged
Conversation
…#3456 and #3457 zio/zio-quill#3457 qualifies batch update RETURNING with the updated table's alias instead of the VALUES alias. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- zio#412: lift(lift(x)) previously compiled but threw RuntimeException at runtime ("Unquotation can only be done from a quoted block."). Now detected at compile time in LiftMacro.apply by inspecting the expression tree for .unquote calls from an inner lift expansion. Uses a custom AST unwrapper since underlyingArgument doesn't strip Inlined nodes with non-empty bindings. - zio#431: liftQuery(List.empty[T]).foreach(...) produced a batch group with SQL but no prepare rows, leading to invalid execution. Now returns Nil (no batch groups) when perRowLifts is empty. Tests for zio#396, zio#239, and zio#335 are included in CriticalIssuesSpec but will fail until zio/zio-quill#3378 is merged by @getquill/maintainers and the quill-engine dependency version is bumped. Authored-by: Colin K. Williams (li-nkSN) <colin@li-nk.org> Refs: zio#412, zio#431 (cherry picked from commit b0fe910)
The check matched any expression ending in a method named unquote, so it also rejected lifting values like w.unquote for a user-defined unquote method, which compiled before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mberndt123
force-pushed
the
nested-lift-empty-batch
branch
from
October 28, 2026 13:45
9ae5679 to
9f72d76
Compare
Collaborator
Author
|
@khajavi, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
lift(lift(x))compiles but fails at runtime (Error prone lift #412).run(liftQuery(Nil).foreach(p => query[Person].insertValue(p)), 1000), runsINSERT INTO ... VALUESwithout any values, which fails (Batch insert with empty collection generates invalid SQL #431). Batch updates fail the same way withFROM (VALUES ) AS ....Solution
The first commit builds against the zio-quill master snapshot that contains zio/zio-quill#3455, #3456 and #3457. The flat join tests in
CriticalIssuesSpec(#396, #239, #335) need #3456, and #3457 changes the expected batch update RETURNING inBatchUpdateValuesMirrorSpecfromps.agetop.age.The second commit is #728 by @li-nkSN, unchanged apart from the package of the new
CriticalIssuesSpec:LiftMacrorejects a lifted expression that is itself a lift.QueryExecutionBatchIterationreturns no batch groups for an empty collection, so nothing is executed.The third commit narrows the nested lift check. It matched any expression ending in a method named
unquote, solift(w.unquote)for a user-definedunquotemethod was rejected as a nested lift, although it compiled before. It now only matches whenunquoteis called on aPlanter.Notes
ctx.translateof a batch action now returns no statements instead of one.Test/compileof all modules,quill-sql/test(280 tests),quill-sql-tests/test(673 tests), and the Postgres tests ofquill-jdbc(148) andquill-jdbc-zio(43) against the docker-compose Postgres. The#412test fails without the nested lift check, and alift(w.unquote)with a user-definedunquotecompiles with the third commit.Checklist
README.mdif applicable[WIP]to the pull request title if it's work in progress@getquill/maintainers
🤖 Generated with Claude Code