From fc65f268faa4f53e1b5c6310a8bc591c9ca7d197 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Thu, 4 Aug 2016 16:59:37 -0700 Subject: [PATCH] Process Function instances in clause handling. r=nalexander --- src/datomish/query/clauses.cljc | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/datomish/query/clauses.cljc b/src/datomish/query/clauses.cljc index ce020148..fb414be7 100644 --- a/src/datomish/query/clauses.cljc +++ b/src/datomish/query/clauses.cljc @@ -13,14 +13,35 @@ [datascript.parser :as dp #?@(:cljs [:refer - [PlainSymbol Predicate Not Or Pattern DefaultSrc Variable Constant Placeholder]])] + [ + Constant + DefaultSrc + Function + Not + Or + Pattern + Placeholder + PlainSymbol + Predicate + Variable + ]])] [honeysql.core :as sql] [clojure.string :as str] ) #?(:clj (:import [datascript.parser - PlainSymbol Predicate Not Or Pattern DefaultSrc Variable Constant Placeholder]))) + Constant + DefaultSrc + Function + Not + Or + Pattern + Placeholder + PlainSymbol + Predicate + Variable + ]))) ;; A ConjoiningClauses (CC) is a collection of clauses that are combined with JOIN. ;; The topmost form in a query is a ConjoiningClauses. @@ -258,6 +279,9 @@ ;; TODO: handle And within the Or patterns. (raise "Non-simple `or` clauses not yet supported." {:clause orc}))) +(apply-function-clause [cc function] + cc) + ;; We're keeping this simple for now: a straightforward type switch. (defn apply-clause [cc it] (condp instance? it @@ -273,6 +297,9 @@ Pattern (apply-pattern-clause cc it) + Function + (apply-function-clause cc it) + (raise "Unknown clause." {:clause it}))) (defn expand-pattern-clauses