pub fn select_card(
declarations: &[Vec<String>],
select: &str,
) -> Result<QueryCard, SqlError>Expand description
One SELECT … FROM t WHERE … as the IDX.QUERY argv that answers
it over t’s declared paths. Values are literals; a $N slot is a
card parameter and is refused here (that is sql compile’s shape).
A query no declared path serves is refused with the same text
sql plan gives it. Never an engine view: a view is a declaration,
and this answers a query now.
let orders: Vec<String> = "TABLE.DECLARE orders PREFIX orders: PK id COLUMN id i64 \
COLUMN user_id i64 COLUMN total f64 INDEX user_id range VALUES total"
.split_whitespace()
.map(String::from)
.collect();
let card = kevy_sql::select_card(&[orders.clone()], "SELECT id FROM orders WHERE user_id = 7").unwrap();
assert_eq!(card.argv.join(" "), "IDX.QUERY orders.user_id EQ 7 FIELDS id");
let refused = kevy_sql::select_card(&[orders], "SELECT id FROM orders WHERE total >= 1").unwrap_err();
assert!(refused.message.contains("total"), "{refused}");