mozilla/mentat

Extend query builder to allow composing parts of the query

Open

#649 geöffnet am 20. Apr. 2018

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Rust (116 Forks)github user discovery
A-queryenhancementgood first bughelp wanted

Repository-Metriken

Stars
 (1.661 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

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.

Contributor Guide