Fix parameter order bug in WHERE clause with :in operator#147
Merged
tamurashingo merged 2 commits intodevelopfrom Feb 4, 2026
Merged
Fix parameter order bug in WHERE clause with :in operator#147tamurashingo merged 2 commits intodevelopfrom
tamurashingo merged 2 commits intodevelopfrom
Conversation
- Add test case to reproduce parameter order bug - Single table query test: parameters with :in are placed first incorrectly - JOIN query test: parameters with :in are placed first incorrectly - Expected: parameters in WHERE clause order - Actual: :in values first, then other parameters - Add migration for test tables (todo, tag, todo_tags) - Add test to clails-test.asd - Add CLAILS_MIGRATION_DIR_0013 to CI configuration
Fixed the issue where parameters in WHERE clause with :in operator were ordered incorrectly. Previously, :in values were added first, followed by regular parameters, which was opposite to their appearance order in the WHERE clause. Changes: - Modified generate-query method in src/model/query.lisp - Collect all parameter specs (both :in-expansion and regular) in order - Process parameters sequentially to maintain WHERE clause order - Add test case for multiple IN clauses with mixed parameters Test results: - Single table query: parameters in correct order - JOIN query: parameters in correct order - Multiple IN clauses: parameters in correct order
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.
Summary
Fixed a bug where SQL parameters were incorrectly ordered when WHERE clause contained both
:inoperator and other comparison operators. The:invalues were placed first, followed by other parameters, which was opposite to their appearance order in the WHERE clause.Changes
generate-querymethod insrc/model/query.lispto maintain parameter orderTest Results
All tests pass with parameters in correct WHERE clause order:
WHERE (col1 = ? AND col2 = ? AND col3 IN (?, ?, ?))→("val1" "val2" 1 2 3)✓WHERE (col1 = ? AND col2 IN (?, ?) AND col3 = ? AND col4 IN (?, ?, ?))→("val1" 100 200 5 10 20 30)✓Related Issue
fix #146