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(any(feature = "sqlite", feature = "postgres", feature = "mysql"))]
11mod sql_exec;
12#[cfg(all(
13    feature = "vista",
14    any(feature = "sqlite", feature = "postgres", feature = "mysql")
15))]
16mod sql_vista;
17#[cfg(any(feature = "sqlite", feature = "postgres", feature = "mysql"))]
18mod table_writes;
19
20#[cfg(feature = "sqlite")]
21pub mod sqlite;
22
23#[cfg(feature = "postgres")]
24pub mod postgres;
25
26#[cfg(feature = "mysql")]
27pub mod mysql;
28
29#[cfg(feature = "rhai")]
30pub mod rhai_engine;
31
32/// The `LIKE` operand for a substring match: `%text%` with the wildcards and
33/// the escape itself escaped, so a `_` or `%` in what the user typed matches
34/// itself. Shared by quicksearch and by the vista `FilterOp::Like`, which is
35/// what keeps the two spelling the same pattern.
36pub(crate) fn like_pattern_str(text: &str) -> String {
37    let escaped = text
38        .replace('$', "$$")
39        .replace('%', "$%")
40        .replace('_', "$_");
41    format!("%{escaped}%")
42}
43
44/// [`like_pattern_str`] over a filter operand, which may be any scalar.
45#[cfg(feature = "vista")]
46pub(crate) fn like_pattern(value: &ciborium::Value) -> String {
47    like_pattern_str(&vantage_vista::operand_text(value))
48}