Skip to content

Conversions from Condition and ConditionExpression into SimpleExpr#886

Merged
tyt2y3 merged 1 commit intoSeaQL:masterfrom
Expurple:condition-into-simple-expr
May 20, 2025
Merged

Conversions from Condition and ConditionExpression into SimpleExpr#886
tyt2y3 merged 1 commit intoSeaQL:masterfrom
Expurple:condition-into-simple-expr

Conversation

@Expurple
Copy link
Copy Markdown
Member

@Expurple Expurple commented May 15, 2025

Yet another type conversion problem that drove me insane.

Motivating examples:

  • I needed Func::coalesce([my_condition.into(), false.into()]). But coalesce accepts SimpleExprs and there's no public way to convert my_condition into SimpleExpr! Not a single public workaround. Which is crazy, because it's obviously already implemented (privately).

  • I needed .expr_as(any![..], "my_alias"). But expr_as accepts Into<SimpleExpr> and any! is a Condition that didn't implement that. This one's less urgent, because there's an .or() chain workaround.

The first one is useful/urgent enough that I'm going to use [patch.crates-io] and immediately depend on this fork in my project.

If you look at the diff, the new conversion method may seem less efficient than the old one, because the conversion now consumes the Condition and there's a new .clone() call because of that. However, nothing has actually changed. The old non-consuming function was doing the same clone()ing inside of its body, and I removed that call.

PR Info

  • Closes: none
  • Dependencies: none
  • Dependents: none

New Features

  • impl From<Condition> for SimpleExpr
  • impl From<ConditionExpression> for SimpleExpr

Bug Fixes

Breaking Changes

Changes

@Expurple Expurple changed the title Convert Condition and ConditionExpression into SimpleExpr Conversions from Condition and ConditionExpression into SimpleExpr May 15, 2025
@tyt2y3 tyt2y3 merged commit a6092ba into SeaQL:master May 20, 2025
20 checks passed
@tyt2y3
Copy link
Copy Markdown
Member

tyt2y3 commented May 21, 2025

merged. can make a patch release this week, or you can still use git dependency

@github-actions
Copy link
Copy Markdown

🎉 Released In 0.32.6 🎉

Thank you everyone for the contribution!
This feature is now available in the latest release. Now is a good time to upgrade!
Your participation is what makes us unique; your adoption is what drives us forward.
You can support SeaQL 🌊 by starring our repos, sharing our libraries and becoming a sponsor ⭐.

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