Open DontBreakAlex opened 2 years ago
Hey @DontBreakAlex, intesting! I don't know we can actually do this, select * from posts where title like '%' || 'abc' || '%'
. However, since ||
concat operator only works on Postgres. So, I'm hesitate to allow SimpleExpr
in like expression. Afterall, the so called like expression is a string. So, why not expr.like(format!("%{}%", val))
?
Hi @billy1624, thanks for your interest. The issue is that my external interface accepts Value
s (not Expr::Value
) for all kinds of various filters, and converting it back to a string is a bit barbarous:
expr.like(format!("%{}%",
if let Value::String(str) = str {
if let Some(str) = str { *str } else { "".to_string() }
} else { "".to_string() }
))
This would also allow writing this:
Expr::expr(Func::lower([expr])).like(Func::lower.args([other_expr]))
However, since
||
concat operator only works on Postgres.
Is this true? as far as I can see sqlite does support concat: https://sqlite.org/lang_corefunc.html#concat
and also it seems to be part of the SQL spec? am I misunderstanding something about this concat?
(I'd like to use concat
to SET
the value in an UPDATE
query)
Motivation
This would allow building dynamic like expressions like this: