Skip to content

Commit

Permalink
Allow pull patterns that are sets (#36)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonas Östlund <[email protected]>
  • Loading branch information
jonasseglare and Jonas Östlund authored Jun 25, 2024
1 parent 8d6cbf0 commit e2c0f3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/datalog/parser/pull.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ legacy-limit-expr = [(\"limit\" | 'limit') attr-name (positive-number | nil)]
legacy-default-expr = [(\"default\" | 'default') attr-name any-value]
```"
[pattern]
(when (sequential? pattern)
(when (or (sequential? pattern)
(set? pattern))
(->> pattern
simplify-pattern-clauses
(mapv parse-attr-spec)
Expand Down
7 changes: 6 additions & 1 deletion test/datalog/parser/pull_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
(testing "simple attribute"
(is (= (dpp/->PullSpec false {:foo {:attr :foo}})
(dpp/parse-pull '[:foo]))))
(testing "simple attribute in set"
(is (= (dpp/->PullSpec false {:foo {:attr :foo}})
(dpp/parse-pull '#{:foo}))))
(testing "namespaced attribute"
(is (= (dpp/->PullSpec false {:db/id {:attr :db/id}
:foo/bar {:attr :foo/bar}})
Expand All @@ -24,7 +27,9 @@
(dpp/parse-pull '[(:foo :default "bar")]))))
(testing "as"
(is (= (dpp/->PullSpec false {:foo {:attr :foo :as "bar"}})
(dpp/parse-pull '[(:foo :as "bar")])))))
(dpp/parse-pull '[(:foo :as "bar")]))))
(testing "bad syntax"
(is (thrown? Throwable (dpp/parse-pull '{:foo 119})))))

(deftest map-specs-test
(testing "wildcard"
Expand Down

0 comments on commit e2c0f3d

Please sign in to comment.