Commits

Anonymous committed 9f053ed

fix lazy versions of find-xxx functions
fix examples in documentation

  • Participants
  • Parent commits a9c9aaf

Comments (0)

Files changed (1)

File src/main/clj/org/bituf/sqlrat/entity.clj

     query A vector containing the SQL in clojure.contrib.sql format. Examples
           are: [\"SELECT * FROM emp\"] and [\"SELECT * FROM emp WHERE id=?\" 56]
   Example:
-    (in-db mysql
-      (db-query (fn [rows] (count rows))
-        [\"SELECT * FROM emp WHERE id=?\" 56]))
-    => 135 ;; returns the row-count
-    (in-db mysql
-      (db-query [\"SELECT * FROM emp WHERE id=?\" 56]))
-    => [{<row1 data>} {<row2 data>} ...] ;; returns the rows as a vector
+    user=> (in-db mysql
+             (db-query (fn [rows] (count rows))
+               [\"SELECT * FROM emp WHERE id=?\" 56]))
+    135 ;; returns the row-count
+    user=> (in-db mysql
+             (db-query [\"SELECT * FROM emp WHERE id=?\" 56]))
+    [{<row1 data>} {<row2 data>} ...] ;; returns the rows as a vector
   See also: with-db-query-results"
   ([f query]
     (if *assert-args* (do
     rows  Is bound to the rows fetched as a result of running the query
     query The SQL query as described in 'db-query' function
   Example:
-    (in-db mysql
-      (with-db-query-results rows [\"SELECT * FROM emp\"]
-        (println rows)))
-    => <rows-data>
+    user=> (in-db mysql
+             (with-db-query-results rows [\"SELECT * FROM emp\"]
+               (println rows)))
+    <rows-data>
   See also: db-query"
   [rows sql-params & body]
   `(db-query (fn [~rows] ~@body) ~sql-params))
     row       The row (map of column-name to column-value) to be saved
     id-column The primary ID column (keyword)
   Examples:
-    (in-txn mysql
-      (save-row :emp {:code 9008 :name \"Joe Walker\"} :empid))
-    => {:empid 197 :code 9008 :name \"Joe Walker\"} ;; 197 is the generated ID
-    (in-txn mysql
-      (save-row :emp {:empid 197 :code 9667 :name \"Joe Hacker\"} :empid))
-    => {:empid 197 :code 1337 :name \"Joe Hacker\"} ;; updated code and name
+    user=> (in-txn mysql
+             (save-row :emp {:code 9008 :name \"Joe Walker\"} :empid))
+    {:empid 197 :code 9008 :name \"Joe Walker\"} ;; 197 is the generated ID
+    user=> (in-txn mysql
+             (save-row :emp {:empid 197 :code 9667 :name \"Joe Hacker\"} :empid))
+    {:empid 197 :code 1337 :name \"Joe Hacker\"} ;; updated code and name
   See also: save"
   [table row id-column]
   (let [id=? (str (name id-column) "=?")]
   "Accept relation metadata as the only argument and return a map of
   that-entity-name to each relation object. This is a memoized fn.
   Example:
-    (let [rels (rel-meta entity)]
-      (dbrel-lookup-by-that-entity rels))
-    => {:that-entity-name1 rel-involving-that-entity1
-        :that-entity-name2 rel-involving-that-entity2
-        ...}"
+    user=> (let [rels (rel-meta entity)]
+             (dbrel-lookup-by-that-entity rels))
+    {:that-entity-name1 rel-involving-that-entity1
+     :that-entity-name2 rel-involving-that-entity2
+     ...}"
   }
   dbrel-lookup-by-that-entity
   (memoize
         (println es)))
   See also: find-by-criteria"
   [entities entity-meta criteria & body]
-  `(let [{cols# :cols where# :where groupby# :groupby other# :other} ~criteria]
-    (find-by-criteria (fn [~entities] ~@body) ~entity-meta
-      {:cols cols# :where where# :groupby groupby# :other other#})))
+  `(find-by-criteria (fn [~entities] ~@body) ~entity-meta ~criteria))
 
 
 (defn find-by-id
           (println rs))))
   See also: find-rels"
   [rel-entities entities that-meta criteria & body]
-  `(let [{cols# :cols where# :where groupby# :groupby other# :other} ~criteria]
-    (find-rels (fn [~rel-entities] ~@body) ~entities ~that-meta
-      {:cols cols# :where where# :groupby groupby# :other other#})))
+  `(find-rels (fn [~rel-entities] ~@body) ~entities ~that-meta ~criteria))
 
 
 (defn find-entity-rels-map
   Arguments:
     entities  (Vector) of entities"
   [entities]
-  (mypp "\nENTITIES ***\n" entities)
+  ;(mypp "\nENTITIES ***\n" entities)
   (if *assert-args*
     (do
       (assert (vector? entities))