Skip to main content

vantage_sql/
lib.rs

1pub mod condition;
2pub mod prelude;
3pub mod primitives;
4
5// Re-export so that macros (sqlite_expr!, sql_expr!, etc.) resolve
6// without downstream crates needing a direct vantage-expressions dependency.
7pub use vantage_expressions;
8pub(crate) mod types;
9
10#[cfg(feature = "sqlite")]
11pub mod sqlite;
12
13#[cfg(feature = "postgres")]
14pub mod postgres;
15
16#[cfg(feature = "mysql")]
17pub mod mysql;
18
19#[cfg(feature = "rhai")]
20pub mod rhai_engine;
21
22/// The `LIKE` operand for a substring match: `%text%` with the wildcards and
23/// the escape itself escaped, so a `_` or `%` in what the user typed matches
24/// itself. Shared by quicksearch and by
25/// [`FilterOp::Like`](vantage_vista::FilterOp::Like), which is what keeps the
26/// two spelling the same pattern.
27pub(crate) fn like_pattern_str(text: &str) -> String {
28    let escaped = text
29        .replace('$', "$$")
30        .replace('%', "$%")
31        .replace('_', "$_");
32    format!("%{escaped}%")
33}
34
35/// [`like_pattern_str`] over a filter operand, which may be any scalar.
36pub(crate) fn like_pattern(value: &ciborium::Value) -> String {
37    like_pattern_str(&vantage_vista::operand_text(value))
38}