Skip to content

feat(db): support string concatenation in queries - #653

Open
oxura wants to merge 1 commit into
cot-rs:masterfrom
oxura:feat/610-string-concat
Open

feat(db): support string concatenation in queries#653
oxura wants to merge 1 commit into
cot-rs:masterfrom
oxura:feat/610-string-concat

Conversation

@oxura

@oxura oxura commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #610.

I went with the explicit concat() shape we discussed in the issue rather than making Expr generic. It now supports all of these:

query!(Product, $name.concat("-") == "mortal-")
query!(Product, $name.concat($title) == "mortalkombat")
query!(Product, $name.concat(" ").concat($title) == "mortal kombat")

The query parser can now keep field references inside method arguments, Expr::Concat lowers to the portable CONCAT(lhs, rhs) function, and the direct field/value path is restricted to TextField receivers. Numeric + stays unchanged.

I added macro coverage for field/literal and field/field concatenation plus a real database test for chained concatenation. The SQLite scenario passes; the same test variants compile for PostgreSQL and MySQL and run when their test databases are available. The focused codegen and macro suites pass, as do clippy, formatting, and diff checks.

@github-actions github-actions Bot added C-lib Crate: cot (main library crate) C-macros Crate: cot-macros C-codegen Crate: cot-codegen labels Aug 30, 2026
@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.48276% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cot-codegen/src/expr.rs 76.19% 3 Missing and 2 partials ⚠️
cot-macros/src/query.rs 92.59% 2 Missing ⚠️
cot/src/db/query/expr.rs 80.00% 0 Missing and 2 partials ⚠️
Flag Coverage Δ
rust 90.11% <84.48%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cot-macros/src/query.rs 91.62% <92.59%> (+0.04%) ⬆️
cot/src/db/query/expr.rs 74.31% <80.00%> (+0.32%) ⬆️
cot-codegen/src/expr.rs 84.00% <76.19%> (-0.18%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-codegen Crate: cot-codegen C-lib Crate: cot (main library crate) C-macros Crate: cot-macros

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support String Concatenation in Query

1 participant