Fix: simplify complex expressions when validating boolean pydantic fields#4790
Merged
georgesittas merged 1 commit intomainfrom Jun 23, 2025
Merged
Conversation
georgesittas
commented
Jun 23, 2025
| def parse_bool(v: t.Any) -> bool: | ||
| if isinstance(v, exp.Boolean): | ||
| return v.this | ||
| if isinstance(v, exp.Expression): |
Contributor
Author
There was a problem hiding this comment.
I've verified by putting an exit(1) within this branch that it wasn't reached by any of our tests, prior to this PR. The only dialect I'm aware of being impacted by this change is T-SQL.
tobymao
approved these changes
Jun 23, 2025
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.
Addresses the bug reported in this Slack thread: https://tobiko-data.slack.com/archives/C044BRE5W4S/p1750228449327769.
T-SQL generates
Booleanvalues likeTRUEinto(1 = 1), which causes issues when it is used in the context of aMODELproperty, such asenabled.For example, if a macro is used and the meta block is rendered, the resulting
Modelexpression is generated and re-parsed in the macro evaluator, resulting in a newParen(Eq(Literal(1), Literal(1))expression for theenabledfield, which resulted in a falsey value with the old logic.