-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
gh-516: support coexistence of SimpleExpr and QueryStatement #572
base: master
Are you sure you want to change the base?
Changes from 3 commits
f8a2cfa
6dc6fc9
bdd64a0
e5f0b64
e88fc4f
2e24c0c
0c79402
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -407,7 +407,11 @@ impl Func { | |
/// | ||
/// let query = Query::select() | ||
/// .expr(Func::coalesce([ | ||
/// Expr::col(Char::SizeW).into(), | ||
/// Query::select() | ||
/// .from(Char::Table) | ||
/// .expr(Func::max(Expr::col(Char::SizeW))) | ||
/// .take() | ||
/// .into(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather be more conservative on this type conversion. Would a method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the slow reply. But doesn't it create confusion that for Seems like this would require redoing the whole api or am I complicating things and it's simpler? |
||
/// Expr::col(Char::SizeH).into(), | ||
/// Expr::val(12).into(), | ||
/// ])) | ||
|
@@ -416,15 +420,15 @@ impl Func { | |
/// | ||
/// assert_eq!( | ||
/// query.to_string(MysqlQueryBuilder), | ||
/// r#"SELECT COALESCE(`size_w`, `size_h`, 12) FROM `character`"# | ||
/// r#"SELECT COALESCE((SELECT MAX(`size_w`) FROM `character`), `size_h`, 12) FROM `character`"# | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And btw, can you add a new test case instead? For better test coverage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by a new test case? I added test cases, insert_coalesce for example. The current test case involves checking for a subquery in coalesce |
||
/// ); | ||
/// assert_eq!( | ||
/// query.to_string(PostgresQueryBuilder), | ||
/// r#"SELECT COALESCE("size_w", "size_h", 12) FROM "character""# | ||
/// r#"SELECT COALESCE((SELECT MAX("size_w") FROM "character"), "size_h", 12) FROM "character""# | ||
/// ); | ||
/// assert_eq!( | ||
/// query.to_string(SqliteQueryBuilder), | ||
/// r#"SELECT COALESCE("size_w", "size_h", 12) FROM "character""# | ||
/// r#"SELECT COALESCE((SELECT MAX("size_w") FROM "character"), "size_h", 12) FROM "character""# | ||
/// ); | ||
/// ``` | ||
pub fn coalesce<I>(args: I) -> FunctionCall | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is we remove this
From
and instead have a concrete implinto_sub_query_expr
inSelectStatement
.What I am concerning is that there may be multiple ways of converting SelectStatement into SimpleExpr, or may be can have additional options.
That'd be more future proof.