commit a7f1c35e1d986ce5707fb3db1aa6c13233c4afed
parent 0bbd621ebf756f76a05e81579f86ca63644e0aa7
Author: Tomas Hlavaty <tom@logand.com>
Date: Sat, 13 Aug 2011 22:00:47 +0200
fix q:par in toxi tags example
Diffstat:
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/test.lisp b/test.lisp
@@ -458,16 +458,17 @@ delete => clear affected instances from cache
(2sql-orm:make-pinstance 'tagmap :bookmark bookmark :tag tag))
(defun build-sql-query (q)
- (if (atom q)
- `(q:select ((2sql-orm:instance bookmark b)) ;; TODO b.*
- (q:from (q:as bookmark b) (q:as tag t) (q:as tagmap m))
- (q:where (q:and (q:= b.oid m.bookmark)
- (q:= t.oid m.tag)
- (q:= t.name ,q))))
- (ecase (car q)
- (and `(q:intersect nil nil nil ,@(mapcar 'build-sql-query (cdr q))))
- (or `(q:union nil nil nil ,@(mapcar 'build-sql-query (cdr q))))
- (not `(q:except nil nil nil ,@(mapcar 'build-sql-query (cdr q)))))))
+ `(q:par
+ ,(if (atom q)
+ `(q:select :b_.* ;; TODO b.* w/o interning (q:dotted-name b :*)
+ (q:from (q:as bookmark b) (q:as tag t) (q:as tagmap m))
+ (q:where (q:and (q:= b.oid m.bookmark)
+ (q:= t.oid m.tag)
+ (q:= t.name ,q))))
+ (ecase (car q)
+ (and `(q:intersect nil nil nil ,@(mapcar 'build-sql-query (cdr q))))
+ (or `(q:union nil nil nil ,@(mapcar 'build-sql-query (cdr q))))
+ (not `(q:except nil nil nil ,@(mapcar 'build-sql-query (cdr q))))))))
(2sql-backend:with-postgresql-connection ("pokus" "tomas" "test123" "localhost")
(2sql-orm:with-pinstance-collector-cache ()
@@ -487,8 +488,8 @@ delete => clear affected instances from cache
(make-tagmap b2 t2)
(flet ((look-up (q)
(2sql-orm:query () ;; TODO cache compiled queries
- `(q:select ((2sql-orm:instance bookmark))
- (q:from (q:as (q:par ,(build-sql-query q)) x))))))
+ `(q:select ((2sql-orm:instance bookmark x))
+ (q:from (q:as ,(build-sql-query q) x))))))
;; Query for “bookmark+webservice+semweb”
(look-up '(and "bookmark" "webservice" "semweb"))
;; Query for “bookmark|webservice|semweb”