Skip to content

Fix: simplify complex expressions when validating boolean pydantic fields#4790

Merged
georgesittas merged 1 commit intomainfrom
jo/fix_boolean_validation_addresses_tsql_bug
Jun 23, 2025
Merged

Fix: simplify complex expressions when validating boolean pydantic fields#4790
georgesittas merged 1 commit intomainfrom
jo/fix_boolean_validation_addresses_tsql_bug

Conversation

@georgesittas
Copy link
Contributor

Addresses the bug reported in this Slack thread: https://tobiko-data.slack.com/archives/C044BRE5W4S/p1750228449327769.

T-SQL generates Boolean values like TRUE into (1 = 1), which causes issues when it is used in the context of a MODEL property, such as enabled.

For example, if a macro is used and the meta block is rendered, the resulting Model expression is generated and re-parsed in the macro evaluator, resulting in a new Paren(Eq(Literal(1), Literal(1)) expression for the enabled field, which resulted in a falsey value with the old logic.

@georgesittas georgesittas requested a review from a team June 23, 2025 16:42
def parse_bool(v: t.Any) -> bool:
if isinstance(v, exp.Boolean):
return v.this
if isinstance(v, exp.Expression):
Copy link
Contributor Author

@georgesittas georgesittas Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@georgesittas georgesittas enabled auto-merge (squash) June 23, 2025 16:55
@georgesittas georgesittas merged commit 50a219c into main Jun 23, 2025
25 checks passed
@georgesittas georgesittas deleted the jo/fix_boolean_validation_addresses_tsql_bug branch June 23, 2025 16:55
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.

2 participants