-
-
Notifications
You must be signed in to change notification settings - Fork 57
Support String Concatenation in Query #610
Copy link
Copy link
Open
Labels
C-libCrate: cot (main library crate)Crate: cot (main library crate)C-macrosCrate: cot-macrosCrate: cot-macrosenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
Activity
Metadata
Metadata
Assignees
Labels
C-libCrate: cot (main library crate)Crate: cot (main library crate)C-macrosCrate: cot-macrosCrate: cot-macrosenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Postgres, MySQL, and SQLite all support string concatenation via
CONCAT/CONCAT_WSfunctions, and Postgres and SQLite additionally support it via the||operator. We currently don't handle either form, and both+and||silently produce broken SQL statements.Example:
Currently produces
which is meaningless for text columns.
Trying
||instead:Also produces:
because
||is being parsed as logicalOR, not SQL string concatenation.Ideally, we want this to yield a
cot::db::query::Expr::Concatexpression:Usage in the
query!macro, and for the+operator specifically, we'd like it to dispatch toExpr::Concatwhen operating on string-typed fields(whenever possible), while continuing to produceExpr::Addfor numeric fieldsOne caveat: this can get tricky for concat chains like below: