File tree Expand file tree Collapse file tree 3 files changed +35
-9
lines changed Expand file tree Collapse file tree 3 files changed +35
-9
lines changed Original file line number Diff line number Diff line change 1+ # WIP
2+
3+ - Fixed query fn results unification #490
4+
15# 1.7.5 - May 4, 2025
26
37- Enable direct-linking on JVM #487 via @raspasov
Original file line number Diff line number Diff line change 167167 (sum-rel b))))))
168168
169169(defn prod-rel
170- ([] (Relation. {} [(da/make-array 0 )]))
170+ ([]
171+ (Relation. {} [(da/make-array 0 )]))
171172 ([rel1 rel2]
172173 (let [attrs1 (keys (:attrs rel1))
173174 attrs2 (keys (:attrs rel2))
544545 rels (for [tuple (:tuples production)
545546 :let [val (tuple-fn tuple)]
546547 :when (not (nil? val))]
547- (prod-rel (Relation. (:attrs production) [tuple])
548- (in->rel binding val)))]
548+ (reduce prod-rel
549+ (collapse-rels
550+ [(Relation. (:attrs production) [tuple])]
551+ (in->rel binding val))))]
549552 (if (empty? rels)
550- (prod-rel production (empty-rel binding ))
553+ (prod-rel
554+ production
555+ (empty-rel binding ))
551556 (reduce sum-rel rels)))
552- (prod-rel (assoc production :tuples []) (empty-rel binding )))]
557+ (prod-rel
558+ (assoc production :tuples [])
559+ (empty-rel binding )))]
553560 (update context :rels collapse-rels new-rel)))
554561
555562; ;; RULES
Original file line number Diff line number Diff line change 7979 (is (= (d/q '[:find ?a1
8080 :where [_ :age ?a1]
8181 [(>= ?a1 22 )]] db)
82- #{[22 ] [37 ]}))
82+ #{[22 ] [37 ]}))
83+
8384 (testing " compare values of different types"
8485 (is (= (d/q '[:find ?e
8586 :where [?e]
137138
138139 (testing " Two conflicting function values for one binding."
139140 (is (= (d/q '[:find ?n
140- :where [(identity 1 ) ?n]
141+ :where
142+ [(identity 1 ) ?n]
141143 [(identity 2 ) ?n]])
142144 #{})))
143145
144146 (testing " Destructured conflicting function values for two bindings."
145147 (is (= (d/q '[:find ?n ?x
146- :where [(identity [3 4 ]) [?n ?x]]
148+ :where
149+ [(identity [3 4 ]) [?n ?x]]
147150 [(identity [1 2 ]) [?n ?x]]])
148151 #{})))
149152
150153 (testing " Rule bindings interacting with function binding. (fn, rule)"
151154 (is (= (d/q '[:find ?n
152155 :in $ %
153- :where [(identity 2 ) ?n]
156+ :where
157+ [(identity 2 ) ?n]
154158 (my-vals ?n)]
155159 db
156160 '[[(my-vals ?x)
229233 [])
230234 #{})))))
231235
236+ ; ; issue-490
237+ (deftest test-fn-call-results-unification
238+ (is (= #{[[:a :a ] :a ]}
239+ (d/q '[:find ?p ?x
240+ :where
241+ [_ :pair ?p]
242+ [(clojure.core/first ?p) ?x]
243+ [(clojure.core/second ?p) ?x]]
244+ [[1 :pair [:a :a ]]
245+ [2 :pair [:b :c ]]]))))
246+
232247(deftest test-predicates
233248 (let [entities [{:db/id 1 :name " Ivan" :age 10 }
234249 {:db/id 2 :name " Ivan" :age 20 }
You can’t perform that action at this time.
0 commit comments