-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Function::Coalesce
not support the coexistence of SimpleExpr
and QueryStatement
#516
Comments
Function::Coalesce
not only support SimpleExpr
Function::Coalesce
not support the coexistence of SimpleExpr
and QueryStatement
Hey @bingryan, thanks for the suggestions!! I think we can make impl Func {
pub fn coalesce<I, T>(args: I) -> FunctionCall
where
I: IntoIterator<Item = T>,
T: Into<SimpleExpr>,
{
FunctionCall::new(Function::Coalesce).args(args)
}
} Which also requires changing impl FunctionCall {
pub fn args<I, T>(mut self, args: I) -> Self
where
I: IntoIterator<Item = T>,
T: Into<SimpleExpr>,
{
self.args = args.into_iter().map(Into::into).collect();
self
}
} And implementing impl From<SelectStatement> for SimpleExpr {
fn from(sel: SelectStatement) -> Self {
SimpleExpr::SubQuery(
None,
Box::new(sel.into_sub_query_statement()),
)
}
} Sounds like a good plan? @ikrivosheev |
@billy1624 I think we need only last one: impl From<SelectStatement> for SimpleExpr {
fn from(sel: SelectStatement) -> Self {
SimpleExpr::SubQuery(
None,
Box::new(sel.into_sub_query_statement()),
)
}
} And should work. We cannot do: impl Func {
pub fn coalesce<I, T>(args: I) -> FunctionCall
where
I: IntoIterator<Item = T>,
T: Into<SimpleExpr>,
{
FunctionCall::new(Function::Coalesce).args(args)
}
} because after this we cannot do: |
Right. User still need Func::coalesce(vec![Query::select().into(), 1.into()]) |
Test language=MySQL
Description
I found it difficult to handle the logic that
Function::Coalesce
supports the coexistence ofSimpleExpr
andQueryStatement
The following logic is correct
mysql query:
but the existing logic does not support the coexistence of
SimpleExpr
andQueryStatement
sea-query/src/func.rs
Lines 430 to 435 in 28cf151
The text was updated successfully, but these errors were encountered: