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

Add Expr::asterisk() and Expr::tbl_asterisk(table: DynIden) methods - Fix #217 #219

Merged
merged 6 commits into from
Jan 2, 2022

Conversation

RomainMazB
Copy link
Contributor

This fix #217, adding two new methods:

  • Expr::wildcard()
Query::select()
    .expr(Expr::wildcard())
    .from(Char::Table)
    .to_string(MysqlQueryBuilder);
SELECT *
FROM `character`
  • Expr::tbl_wildcard(table: DynIden)
Query::select()
    .expr(Expr::tbl_wildcard(Char::Table))
    .column((Font::Table, Font::Name))
    .from(Char::Table)
    .inner_join(Font::Table, Expr::tbl(Char::Table, Char::FontId).equals(Font::Table, Font::Id))
    .to_string(MysqlQueryBuilder);
SELECT `character`.*, `font`.`name`
FROM `character`
INNER JOIN `font` ON `character`.`font_id` = `font`.`id`

src/types.rs Outdated
Comment on lines 66 to 67
Wildcard,
TableWildcard(DynIden)
Copy link
Member

Choose a reason for hiding this comment

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

@billy1624 how will this affect SeaORM / SeaSchema?

Copy link
Member

Choose a reason for hiding this comment

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

No impact for SeaSchema. But this part of code has to be updated in SeaORM.
https://github.com/SeaQL/sea-orm/blob/82bad4a376efb875ac32ab601ac2cd9cce191e3f/src/query/combine.rs#L45-L62

@tyt2y3
Copy link
Member

tyt2y3 commented Dec 31, 2021

Thank you for the contribution! Looks good all-in-all.

Sorry for the name argument. * has not got an official name in SQL, but I am pretty sure it is not called 'wildcard' (which is %), perhaps it could be named Star or Asterisk?

@RomainMazB
Copy link
Contributor Author

Yeah, no problem for the name: I call * wildcard because this is how it's called in filesystem paths libraries like globset.

I'll rename all the appellation wildcard to asterisk because even if star is shorter, I feel uncomfortable with tbl_star() method

@RomainMazB RomainMazB changed the title Add Expr::wildcard() and Expr::tbl_wildcard(table: DynIden) methods - Fix #217 Add Expr::asterisk() and Expr::tbl_asterisk(table: DynIden) methods - Fix #217 Dec 31, 2021
Copy link
Member

@tyt2y3 tyt2y3 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

@tyt2y3 tyt2y3 merged commit 4bc3dd1 into SeaQL:master Jan 2, 2022
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.

Add Expr::asterisk() and Expr::tbl_asterisk(IntoTableRef)
3 participants