Extend query builder to allow composing parts of the query #222

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

Right now, the query builder takes a blob of EDN and allows to bind values. I would like to be able to compose the parts of the query in a granular fashion. By manipulating the string, I hacked in support for :order and :limit, but I'd like to be able to say

let qb = QueryBuilder::new();
qb.add_find("?x ?y");
qb.add_where("[?x :is 10]");
if limit {
  qb.set_limit("20");
}
if sort {
  qb.set_order("?y ?x");
}

I think that parsing any string given to the QueryBuilder into a FindQuery up front, and then updating the FindQuery with the builder pattern, should do the trick.

This is follow-up to https://github.com/mozilla/mentat/pull/602.

Right now, the query builder takes a blob of EDN and allows to bind values. I would like to be able to compose the parts of the query in a granular fashion. By manipulating the string, I hacked in support for `:order` and `:limit`, but I'd like to be able to say ``` let qb = QueryBuilder::new(); qb.add_find("?x ?y"); qb.add_where("[?x :is 10]"); if limit { qb.set_limit("20"); } if sort { qb.set_order("?y ?x"); } ``` I think that parsing any string given to the `QueryBuilder` into a `FindQuery` up front, and then updating the `FindQuery` with the builder pattern, should do the trick. This is follow-up to https://github.com/mozilla/mentat/pull/602.
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#222
No description provided.