#[non_exhaustive]pub struct QueryCard {
pub name: String,
pub argv: Vec<String>,
pub params: Vec<CardParam>,
}Expand description
A compiled runtime template: the exact IDX.QUERY … argv with $N
slots left in place. The application substitutes real values for the
slots and sends the argv as-is — there is no runtime SQL.
let c = kevy_sql::compile(
"CREATE TABLE orders (id bigint PRIMARY KEY, user_id bigint);
CREATE INDEX ON orders (user_id);
CREATE VIEW by_user AS SELECT * FROM orders WHERE user_id = $1;",
)?;
let card = &c.query_cards[0];
// bind $1 = 42, then send the argv as-is
let argv: Vec<String> =
card.argv.iter().map(|a| if a == "$1" { "42".into() } else { a.clone() }).collect();
assert_eq!(argv[..4], ["IDX.QUERY", "orders.user_id", "EQ", "42"]);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringThe view name the card compiles.
let c = kevy_sql::compile(
"CREATE TABLE orders (id bigint PRIMARY KEY, user_id bigint);
CREATE INDEX ON orders (user_id);
CREATE VIEW by_user AS SELECT * FROM orders WHERE user_id = $1;",
)?;
assert_eq!(c.query_cards[0].name, "by_user");argv: Vec<String>The full argv template (["IDX.QUERY", "orders.user_id", "EQ", "$1", …]).
let c = kevy_sql::compile(
"CREATE TABLE orders (id bigint PRIMARY KEY, user_id bigint);
CREATE INDEX ON orders (user_id);
CREATE VIEW by_user AS SELECT * FROM orders WHERE user_id = $1;",
)?;
assert_eq!(c.query_cards[0].argv[..4], ["IDX.QUERY", "orders.user_id", "EQ", "$1"]);params: Vec<CardParam>The $N slots in ascending order.
let c = kevy_sql::compile(
"CREATE TABLE orders (id bigint PRIMARY KEY, user_id bigint);
CREATE INDEX ON orders (user_id);
CREATE VIEW by_user AS SELECT * FROM orders WHERE user_id = $1;",
)?;
let slots: Vec<u32> = c.query_cards[0].params.iter().map(|p| p.n).collect();
assert_eq!(slots, [1]);Trait Implementations§
impl Eq for QueryCard
impl StructuralPartialEq for QueryCard
Auto Trait Implementations§
impl Freeze for QueryCard
impl RefUnwindSafe for QueryCard
impl Send for QueryCard
impl Sync for QueryCard
impl Unpin for QueryCard
impl UnsafeUnpin for QueryCard
impl UnwindSafe for QueryCard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more