From a275c18d124af67c46f1e623e505da8491a3d096 Mon Sep 17 00:00:00 2001
From: Cam Saul <cam@geotip.com>
Date: Tue, 7 Jul 2015 16:25:36 -0700
Subject: [PATCH] test fix

---
 src/metabase/db.clj | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/metabase/db.clj b/src/metabase/db.clj
index c2134196435..532c96817f2 100644
--- a/src/metabase/db.clj
+++ b/src/metabase/db.clj
@@ -288,15 +288,19 @@
 
 ;; ## EXISTS?
 
-(defn exists?
+(defn -exists?
+  [entity kwargs]
+  (boolean (seq (k/select (i/entity->korma entity)
+                          (k/fields [:id])
+                          (k/where kwargs)
+                          (k/limit 1)))))
+
+(defmacro exists?
   "Easy way to see if something exists in the db.
 
     (exists? User :id 100)"
   [entity & {:as kwargs}]
-  (boolean (seq (k/select (i/entity->korma entity)
-                          (k/fields [:id])
-                          (k/where (if (seq kwargs) kwargs {}))
-                          (k/limit 1)))))
+  `(-exists? ~entity '~(if (seq kwargs) kwargs {})))
 
 ;; ## CASADE-DELETE
 
-- 
GitLab