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