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.
Edited PR Info
Expr
andSimpleExpr
, which now simply forward toExprTrait
methods. I call it small, because all signatures are exactly the same and the compiler will simply suggest addinguse sea_query::ExprTrait
, which is enough to fix the breakage.impl ExprTrait for C: ColumnTrait
insea_orm
.ColumnTrait
methods. Their signatures don't match exactly, so there's going to be more breakage than in case ofsea_query
.New Features
trait ExprTrait
Expr
- andSimpleExpr
-like "operator" methods.impl<T> ExprTrait for T where T: Into<SimpleExpr>
Expr
,SimpleExpr
, and also all otherInto<SimpleExpr>
types, likeValue
orFunctionCall
.impl PgExpr
forFunctionCall
,ColumnRef
,Keyword
,LikeExpr
,Value
.ExprTrait
: adding "operator" methods to all "smaller" types.impl SqliteExpr
forFunctionCall
,ColumnRef
,Keyword
,LikeExpr
,Value
.ExprTrait
: adding "operator" methods to all "smaller" types.impl From<LikeExpr> for SimpleExpr
fn like_like
. But this part is optional and I don't mind reverting this if you want.Bug Fixes
None
Breaking Changes
None
Changes
None
Unedited original notes
This is a "draft" PR with only implementation and almost no new documentation or tests. I'd like to hear some feedback before commiting to doing that.
I added a very minimal doctest on
ExprTrait
definition, as a showcase of expressions which are now possible to write without wrapping everything in layers ofExpr::something(...)
. If it's not impressive or hard to understand, please let me know, I'll add more examples/comparisons. See also examples in #771 and #770. It's hard to understate: THIS IS A HUGE USABILITY WIN. I use SeaORM at work, I'm a relatively experienced user (and a contributor) at this point, but theExpr
/SimpleExpr
stuff still drives me crazy from time to time.Apart from that doctest, there are no new tests, but note that
ExprTrait
methods are actually 100% covered by existing doctests of inherentExpr
/SimpleExpr
methods, which now call the trait under the hood.This PR proposes a small breaking change, and I plan a few more, described in "PR Info". Let's also discuss this. Are you open to merging these? I'd really like to see them included. It makes things SO ELEGANT, compared to what we had. I think, now is a great time for this, as you go through unstable release candidates before major SeaORM 1.0.0.