Commit bf7f1de
fix(expressions): accept a bare true / false as an AND / OR / NOT operand (#3917)
* fix(expressions): accept a bare true / false as an AND / OR / NOT operand
The BooleanLiteral to AlwaysTrue/AlwaysFalse conversion was attached only to
the whole expression, so a bare boolean reached And/Or/Not as a
BooleanLiteral and failed pydantic validation:
parse("(false) or foo = 1") -> EqualTo(foo, 1)
parse("false or foo = 1") -> ValidationError: 1 validation error for Or
Seeding a filter with `true` and appending clauses is a common way to build
a row_filter, so `row_filter="true and status = 'x'"` raised instead of
scanning. Give `predicate` its own copy of the boolean element that folds to
AlwaysTrue/AlwaysFalse; `literal` and `literal_set` keep the raw
BooleanLiteral, so `foo = true` and `foo in (true, false)` are unchanged.
Co-Authored-By: Claude Code <noreply@anthropic.com>
* Fix parse action for always_boolean to use strtobool
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* refactor(expressions): fold a bare boolean at the predicate level
The extra `boolean.copy()` is not needed. `handle_always_expression` already
did this fold; it was only attached to the whole expression, which is why
`(true) and foo = 1` worked and `true and foo = 1` did not -- infix_notation
returns the same Forward that a parenthesized sub-expression recurses through,
so the fold ran only when an operand happened to take that path.
Attach it to `predicate` instead so every operand folds. `literal` and
`literal_set` consume the boolean further in, so `foo = true` and
`foo in (true, false)` keep the raw `BooleanLiteral`. The top-level attachment
is now unreachable and is removed. Tests are unchanged.
Co-Authored-By: Claude Code <noreply@anthropic.com>
---------
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>1 parent 9299bdb commit bf7f1de
2 files changed
Lines changed: 39 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
271 | 280 | | |
272 | 281 | | |
273 | 282 | | |
| |||
280 | 289 | | |
281 | 290 | | |
282 | 291 | | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
306 | 300 | | |
307 | 301 | | |
308 | 302 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
272 | 273 | | |
273 | 274 | | |
274 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
0 commit comments