Fork me on GitHub
#xtdb
<
2022-01-08
>
match3723:01:55

Is this a bug?

user=> (xt/q (xt/db node) '{:find [(pull v? [*])] :where [[v? :x/type :v] (or-join [v?] [v? :v/vin "vin-1"])]  :limit 10} )
; get 1 record with attribute :v/vin as "vin-1"
user=> (xt/q (xt/db node) '{:find [(pull v? [*])] :where [[v? :x/type :v] (or-join [v?] [v? :v/vin x])] :in [[x ...]]  :limit 10} ["vin-1"] )
; get 10 records with different attribute values for :v/vin 

refset23:01:15

Hey, I think you need to add the x to the or-join rule-var vector (i.e. (or-join [?v x] ...) which determines the scoping) and it should work. In other words, you currently have two completely disconnected (non-unified) logic vars for x I was just testing it with:

(with-open [n (xt/start-node {})]
  (xt/submit-tx n [[::xt/put {:xt/id :foo :a 1 :t :t}]
                   [::xt/put {:xt/id :bar :a 2 :t :t}]])
  (xt/sync n)
  [(xt/q (xt/db n) '{:find [e]
                     :where [[e :t :t]
                             (or-join [e]
                                      [e :a 1])]
                     :limit 10})
   (xt/q (xt/db n) '{:find [e]
                     :in [[x ...]]
                     :where [[e :t :t]
                             (or-join [e x]
                                      [e :a x])]
                     :limit 10}
         [1])]
  )

match3703:01:33

Cool. Thanks!

match3703:01:07

Maybe worth pointing out this in doc (treat passed in arguments as logic variables)?

refset11:01:55

Great 🙂 > Maybe worth pointing out this in doc (treat passed in arguments as logic variables)? Sure thing, I'll have a look at how to make this clearer :thumbsup:

👍 1