That’s probably accurate
Ok looking at this, I would say that clara.rules/query(https://github.com/cerner/clara-rules/blob/master/src/main/clojure/clara/rules.cljc#L47-L57) 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: https://github.com/cerner/clara-rules/blob/master/src/main/clojure/clara/rules/engine.cljc#L1976 a disjunction between the keys of the params provided and params on the node itself(https://github.com/cerner/clara-rules/blob/master/src/main/clojure/clara/rules/engine.cljc#L432) 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: https://github.com/cerner/clara-rules/blob/master/src/main/clojure/clara/rules/engine.cljc#L1978
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: https://github.com/cerner/clara-rules/issues/454 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?
yes
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
[:?x]
[?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.