Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ec027900 committed Aug 16, 2020
1 parent 5b13c56 commit b559d93
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ This is a history of changes to clara-rules.
# 0.21.0 SNAPSHOT
* Add names to anonymous functions generated by rule compilation, see [issue 261](https://github.com/cerner/clara-rules/issues/261) and [issue 291](https://github.com/cerner/clara-rules/issues/291)
* Add alpha node types, see [issue 237](https://github.com/cerner/clara-rules/issues/237)
* BREAKING: Validate parameters provided to queries exist on query and compilation. see [issue 454](https://github.com/cerner/clara-rules/issues/454)
* Validate parameters provided to queries exist on query and compilation.
Throws exception if query doesn't specify appropriate parameters. see [issue 454](https://github.com/cerner/clara-rules/issues/454)

# 0.20.0
* Add a flag to omit compilation context (used by the durability layer) after Session compilation to save space when not needed. Defaults to true. [issue 422](https://github.com/cerner/clara-rules/issues/422)
Expand Down
2 changes: 1 addition & 1 deletion src/main/clojure/clara/rules/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@
(create-id-fn)
{:node-type :query
:query production})
(throw (ex-info "QueryNode does not contain bindings specified in parameters."
(throw (ex-info "Query does not contain bindings specified in parameters."
{:expected-bindings (:params production)
:available-bindings ancestor-bindings
:query (:name production)}))))))))
Expand Down
3 changes: 2 additions & 1 deletion src/main/clojure/clara/rules/engine.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1988,7 +1988,8 @@
(platform/throw-error (str "The query " query " is invalid or not included in the rule base.")))
(when-not (= (into #{} (keys params)) ;; nil params should be equivalent to #{}
(:param-keys query-node))
(platform/throw-error (str "The query " query " was not provided with the correct parameters, expected: " (:param-keys query-node) ", provided: " (set (keys params)))))
(platform/throw-error (str "The query " query " was not provided with the correct parameters, expected: "
(:param-keys query-node) ", provided: " (set (keys params)))))

(->> (mem/get-tokens memory query-node params)

Expand Down
13 changes: 5 additions & 8 deletions src/test/clojure/clara/test_compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
[clara.rules.engine :as eng]
[clojure.string :as str]
[clara.rules.accumulators :as acc]
[clojure.main :as m]
[clara.rules.compiler :as com])
[clojure.main :as m])
(:import [clara.rules.engine
AlphaNode
TestNode
Expand Down Expand Up @@ -70,9 +69,7 @@
:fact-binding :?c}]
:params #{:?b}
:name "a-query"}]
(try (com/mk-session [[query]])
(catch ExceptionInfo exc
(is (= (ex-data exc)
{:expected-bindings #{:?b}
:available-bindings #{:?c}
:query "a-query"}))))))
(tu/assert-ex-data {:expected-bindings #{:?b}
:available-bindings #{:?c}
:query "a-query"}
(r/mk-session [query]))))

0 comments on commit b559d93

Please sign in to comment.