Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select any SimpleExpr via QuerySelect #1696

Closed
billy1624 opened this issue Jun 9, 2023 · 2 comments
Closed

Select any SimpleExpr via QuerySelect #1696

billy1624 opened this issue Jun 9, 2023 · 2 comments
Assignees
Milestone

Comments

@billy1624
Copy link
Member

Discussed on Discord: https://discord.com/channels/873880840487206962/1115651321995993128

Motivation

Now we cannot select SimpleExpr directly via QuerySelect interface.

let mut find = cake::Entity::find();

find.query()
    .expr(Expr::col(Alias::new("some_column")))
    .exprs([
        Expr::col(Alias::new("some_column")),
        Expr::col(Alias::new("some_column")),
    ])

Proposed Solutions

A new API can provide a shortcut for it.

cake::Entity::find()
    .expr(Expr::col(Alias::new("some_column")))
    .exprs([
        Expr::col(Alias::new("some_column")),
        Expr::col(Alias::new("some_column")),
    ])
@billy1624 billy1624 self-assigned this Jun 9, 2023
@billy1624
Copy link
Member Author

I will create a PR for this :)

@billy1624 billy1624 added this to the 0.12.x milestone Jun 9, 2023
@darkmmon darkmmon mentioned this issue Jun 12, 2023
2 tasks
darkmmon added a commit to darkmmon/sea-orm that referenced this issue Jun 12, 2023
darkmmon added a commit to darkmmon/sea-orm that referenced this issue Jun 13, 2023
billy1624 added a commit that referenced this issue Jun 13, 2023
* Test suit load environment variable from env files

* Added expr() and exprs() for QuerySelect trait and Minor typo fix

* fmt

* Added doc testing for the new functions

* Remove excess comment for doc test

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>

* Remove excess comment for doc test

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>

* updated doc tests to make example more realistic

* changed doc test again for more realistic query and added expr_as()

* aligned expr_as() alias input with column_as() input

* update doc test for expr_as() according to previous changes

---------

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
@billy1624
Copy link
Member Author

Closed by #1702

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

No branches or pull requests

1 participant