Advertisement
Zak

CQL substitution fail

Zak
Jun 15th, 2011
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn cat-and-subs [cat]
  2.   (-> @(q/select categories
  3.                  (q/where (and (not (= :super nil))
  4.                                (= :super cat))))
  5.       map-id
  6.       (conj cat)))
  7.  
  8. (defn items-by-cat [cat]
  9.   (-> items
  10.       (q/select (q/where (p/in :category
  11.                                (cat-and-subs cat))))))
  12.  
  13. @(items-by-cat 1) ; category 1 is not a super of anything - works fine
  14.  
  15. @(items-by-cat 3) ; 3 is the super of 5, this throws "The column index is out of range: 2, number of columns: 1."
  16.  
  17. (cat-and-subs 3) ; returns (3 5)
  18.  
  19. @(-> items
  20.       (q/select (q/where (p/in :category [3 5])))) ; this works, and by substitution SHOULD be the same as (items-by-cat 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement