Fork me on GitHub

That’s probably accurate


Ok looking at this, I would say that clara.rules/query( could use a bit of validation on the args. As the user provides both the query and key/values to query already it should be pretty straight forward to determine if the map of arguments match that of the params on the query itself. similar to how we validate that the query is in rulebase today: a disjunction between the keys of the params provided and params on the node itself( in the event that the user provided more/less the query behaves quite differently as demonstrated in the examples provided. This simply comes down to the implementation of query itself:

👍 8

as it uses bindings to retrieve the tokens from memory


so the assumption i mentioned above is technically true, and has to be true as it would be inforced by the behavior of the memory


I have logged: for the conversation above. Please feel free to add Comments/Concerns, it seems pretty straight forward and if i get time this weekend i might knock it out


I'm not completely sure I understand everything you said. Can I only use = in query constraints?


in the context of the query

(= ?x x)
is defining a binding of :?x, when querying the memory of a session the bindings of the query denoted by the query parameters are used. meaning a defquery like:
(defquery some-query
  [?a <- SomeFact (= ?x x) (= ?y y)])
would use:
{:?x <val>}
to retrieve the values of the query from the session.


where value is provided from the clara.rule/query function like:

(r/query session some-query :?x 42)


however today clara allows arbitrary values to be provided to the query, like:

(r/query session some-query :?x 42 :?v 1 :?w 2)
this causes the retrieval from memory to miss tokens as it simply assumes that all values passed are valid bindings.