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