Skip to content

Unify Expr and SimpleExpr as one type#889

Merged
tyt2y3 merged 8 commits intoSeaQL:masterfrom
Huliiiiii:expr-1
May 28, 2025
Merged

Unify Expr and SimpleExpr as one type#889
tyt2y3 merged 8 commits intoSeaQL:masterfrom
Huliiiiii:expr-1

Conversation

@Huliiiiii
Copy link
Copy Markdown
Member

@Huliiiiii Huliiiiii commented May 22, 2025

PR Info

  • Closes
  • Dependencies:
  • Dependents:

New Features

  • SimpleExpr now has all methods from Expr.

Bug Fixes

Breaking Changes

  • Expr is now an alias of SimpleExpr.
    • How to migrate: if your code doesn't rely on these being two different types, everything should just work. But if you had impl Foo for Expr and impl Foo for SimpleExpr, your code won't compile and you need to delete one of the impls.

Changes

  • Deprecate SimpleExpr::expr and add SimpleExpr::new which is more consistent with Rust conventions.

@Huliiiiii Huliiiiii mentioned this pull request May 22, 2025
8 tasks
src/expr.rs Outdated
/// );
/// ```
#[allow(clippy::self_named_constructors)]
#[deprecated(since = "0.32.0", note = "Please use the [`SimpleExpr::new`] method")]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

since needs to be updated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, I'm not sure now to properly deal with this. But the first release with your changes will probably be called 1.0.0-rc1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've updated master to 1.0.0-rc1, so this can be changed now 8b7dffb

Comment on lines +1404 to 1406
pub fn new(expr: impl Into<Self>) -> Self {
expr.into()
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

new seems the same as from. Is it really needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this aligns better with Rust conventions.
new, expr, and from essentially do the same thing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think, new is kinda unnecessary (we already have variant constructors addition to expr and from). But we can have it. I'll leave this up to maintainers to decide

Copy link
Copy Markdown
Member

@Expurple Expurple left a comment

Choose a reason for hiding this comment

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

Thank you. Everything seems good, cargo test passes without warnings.

But before merging, I think we need to check the breakage in sea_orm. Can you make a draft PR in sea_orm that imports this branch of sea_query and fixes the breakage?

Also, I'd reword the changelog a little:

New Features

  • SimpleExpr now has all methods from Expr.

Breaking Changes

  • Expr is now an alias of SimpleExpr.
    • How to migrate: if your code doesn't rely on these being two different types, everything should just work. But if you had impl Foo for Expr and impl Foo for SimpleExpr, your code won't compile and you need to delete one of the impls.

I assume, we'll need some "migration guide" for sea_query 1.0. So, I'm going to write a "How to migrate" section for every breaking change. You can also do this in your future PRs.

@Expurple
Copy link
Copy Markdown
Member

Expurple commented May 24, 2025

Waiting for Cargo.toml changes in SeaQL/sea-orm#2604, so that we can trigger a CI run there, to make sure that we actually noticed and fixed all the breakage there.

Meanwhile, @tyt2y3, can you trigger the CI on this PR?

After running the CI on both PRs, this PR can be merged (into an appropriate branch for breaking changes)

@tyt2y3
Copy link
Copy Markdown
Member

tyt2y3 commented May 27, 2025

@Huliiiiii after this PR CI should auto-trigger for you :)

@tyt2y3 tyt2y3 changed the title Remove Expr, re-export Expr as type alias of SimpleExpr Unity Expr and SimpleExpr as one type May 27, 2025
@tyt2y3 tyt2y3 changed the title Unity Expr and SimpleExpr as one type Unify Expr and SimpleExpr as one type May 27, 2025
@Expurple
Copy link
Copy Markdown
Member

Apart from unrelated clippy complaints, the CI passes on both PRs 🎉

This PR can be merged now.

After that, we can finish with merging SeaQL/sea-orm#2604 (comment)

@tyt2y3 tyt2y3 merged commit 4c48574 into SeaQL:master May 28, 2025
@Huliiiiii Huliiiiii mentioned this pull request Aug 2, 2025
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.

3 participants