Skip to content

Render is / is not inside an OR condition as = / != like the comparison path - #35

Merged
rasuvaeff merged 1 commit into
masterfrom
fix/or-is-operator
Sep 13, 2026
Merged

rasuvaeff merged 1 commit into
masterfrom
fix/or-is-operator

Conversation

@rasuvaeff

Copy link
Copy Markdown
Owner

Fixes #34

Problem

withOrCondition(['status' => ['is', 'pending']]) — or an OrConditionSpecification built directly with ['is', 'status', 'pending'] — reached yiisoft/db verbatim and rendered "status" IS 'pending'. IS accepts only NULL / TRUE / FALSE / UNKNOWN on MySQL, MariaDB and PostgreSQL (ERROR 1064 / syntax error at or near "'pending'"). SQLite treats IS as null-safe equality and accepts it, which is why the integration suite stayed green.

The comparison path was already fine: visitComparison() maps is → = and is not → != and lets yiisoft/db render IS NULL for 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. A null operand still renders IS NULL / IS NOT NULL; anything else a plain equality — what new 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 into IN ('is', 'pending').

Tests

  • QueryBuildingVisitorTest: provider with null / string / bool operands, upper-case IS, and the untouched forms (non-string column, two operands).
  • SqliteIntegrationTest::orConditionIsRendersAsEquality asserts the SQL (= 'pending', IS NOT NULL, no IS '), not only the rows — the rows are identical on SQLite either way.

composer build — 309 tests, 2934 assertions, green. composer rector — green.

…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
@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 5292546f-6e8c-4e13-9d03-2c5536fd5c05


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rasuvaeff
rasuvaeff merged commit ed169f9 into master Sep 13, 2026
10 checks passed
@rasuvaeff
rasuvaeff deleted the fix/or-is-operator branch September 13, 2026 15:47
@rasuvaeff rasuvaeff mentioned this pull request Sep 13, 2026
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

Successfully merging this pull request may close these issues.

OR condition with 'is' / 'is not' and a non-null operand renders invalid SQL (col IS 'value') on MySQL and PostgreSQL

1 participant