Bail out with a helpful error message when encountering an unused binding #254

Open
opened 2020-08-06 16:57:24 +00:00 by gburd · 0 comments
gburd commented 2020-08-06 16:57:24 +00:00 (Migrated from github.com)

Given a String url...

let query = r#"[:find ?eid :where [?eid :page/url ?url]]"#;
let args = QueryInputs::with_value_sequence(vec![(var!(?url), url.clone().into())]);
let rows = transaction.q_once(query, args).into_rel_result()?;

Won't actually bind url variable to ?url, and will return an unfiltered list of entids. To me, that was surprising - I didn't realize I needed to explicitly name my inputs via an ":in" clause. So, this works as expected: [:find ?eid :in ?url :where [?eid :page/url ?url]].

Similarly to how we bail on encountering unbound :in variables, perhaps we can also bail on encountering an unused input? It seems like a programming error, and should save people time as they're learning how to query.

Currently we explicitly discard any bindings not mentioned in the :in clause.

Given a String url... ``` let query = r#"[:find ?eid :where [?eid :page/url ?url]]"#; let args = QueryInputs::with_value_sequence(vec![(var!(?url), url.clone().into())]); let rows = transaction.q_once(query, args).into_rel_result()?; ``` Won't actually bind `url` variable to `?url`, and will return an unfiltered list of entids. To me, that was surprising - I didn't realize I needed to explicitly name my inputs via an ":in" clause. So, this works as expected: `[:find ?eid :in ?url :where [?eid :page/url ?url]]`. Similarly to how we bail on encountering unbound `:in` variables, perhaps we can also bail on encountering an unused input? It seems like a programming error, and should save people time as they're learning how to query. Currently we explicitly discard any bindings not mentioned in the :in clause.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: greg/mentat#254
No description provided.