Repository navigation
Render is / is not inside an OR condition as = / != like the comparison path - #35
Merged
Merged
Conversation
…on path An OR condition written as ['is', value] or handed to OrConditionSpecification as ['is', column, value] reached yiisoft/db verbatim and rendered `col IS 'value'` — a syntax error on MySQL and PostgreSQL that only SQLite accepts. normalizeOrCondition() now maps is / is not to = / != exactly as visitComparison() does, so a null operand still renders IS NULL / IS NOT NULL and any other operand a plain equality. Fixes #34
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merged
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.
Fixes #34
Problem
withOrCondition(['status' => ['is', 'pending']])— or anOrConditionSpecificationbuilt directly with['is', 'status', 'pending']— reached yiisoft/db verbatim and rendered"status" IS 'pending'.ISaccepts onlyNULL/TRUE/FALSE/UNKNOWNon MySQL, MariaDB and PostgreSQL (ERROR 1064/syntax error at or near "'pending'"). SQLite treatsISas null-safe equality and accepts it, which is why the integration suite stayed green.The comparison path was already fine:
visitComparison()mapsis→=andis not→!=and lets yiisoft/db renderIS NULLfor a null operand. Only the OR path skipped that mapping.Fix
normalizeOrCondition()applies the same mapping to every three-element[is|is not, column, value]form, whatever the operand. Anulloperand still rendersIS NULL/IS NOT NULL; anything else a plain equality — whatnew ComparisonSpecification('status', 'pending', 'is')already produced.Narrowing the
fromArray()shorthand instead was considered and rejected (see the issue): it leaves the direct constructor broken and turns the input intoIN ('is', 'pending').Tests
QueryBuildingVisitorTest: provider with null / string / bool operands, upper-caseIS, and the untouched forms (non-string column, two operands).SqliteIntegrationTest::orConditionIsRendersAsEqualityasserts the SQL (= 'pending',IS NOT NULL, noIS '), not only the rows — the rows are identical on SQLite either way.composer build— 309 tests, 2934 assertions, green.composer rector— green.