Repository navigation
Fix where_not_null adding a stray binding - #320
Merged
Merged
Conversation
The qmark branch of BaseGrammar.process_wheres skipped the binding for NULL clauses but not NOT NULL ones, so where_not_null/or_where_not_null appended a None with no placeholder and shifted every later binding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
where_not_null/or_where_not_nulladded aNonebinding with no matching?placeholder. Every later binding shifted by one, so e.g..where_not_null("x").where("created_at", ">=", d)comparedcreated_atagainst NULL and returned no rows.Root cause
BaseGrammar.process_wheres(qmark branch,src/fastapi_startkit/masoniteorm/query/grammars/BaseGrammar.py) excludedNULLclauses from binding but notNOT NULLones. The builder is correct; the fix is in the grammar, so it applies to all four dialects.where_column,where_rawwithout bindings andwhere_exists/where_hassubqueries were checked: they don't add stray bindings themselves, but awhere_not_nullinside an exists subquery leaked theNoneto the outer query. The same fix covers that case.Tests
tests/masoniteorm/query/grammars/test_null_where_bindings_grammar.py: for sqlite/mysql/postgres/mssql, checks that the placeholder count equals the binding count and that values stay in order. Covers all four null methods followed by where/where_in/or_where, plus where_column/where_raw and an exists subquery.tests/masoniteorm/sqlite/builder/test_sqlite_null_where_bindings.py: sqlite integration test reproducing the date-filter case.Note: the builder has no
where_date/where_betweenmethods, so the tests usewhere(col, ">=", date), which hits the same bug.🤖 Generated with Claude Code