             (sql/with-query-results rows ["VALUES IDENTITY_VAL_LOCAL()"] (:1 (first rows))))] ; XXX: db-vendor-specific
       (get-record model-name id))))
 
-(defn get-record [model-name id]
-  (sql/with-connection db
-    (sql/with-query-results rows [(format "select * from %s where id = ?" (table-name model-name)) id]
-      (if (empty? rows) (throw (IllegalArgumentException. "Record does not exist")))
-      (merge {} (first rows)))))
-
-(defn find-records [model-name attributes]
+(defn find-records
+  "Returns a vector of records matching (-> attributes to-conditions)."
+  [model-name attributes]
   (let [[parameterized-where & values] (to-conditions attributes)
         select-query (format "select * from %s where %s" (table-name model-name) parameterized-where)]
     (sql/with-connection db
       (sql/with-query-results rows (apply vector select-query values)
         (doall (map #(merge {} %) rows))))))
 
-(defn update [model-name attributes]
+(defn update
+  "Updates by (partial-record :id), updating only those columns included in partial-record."
+  [model-name partial-record]
   (sql/with-connection db
-    (sql/update-values (table-name model-name) ["id = ?" (:id attributes)] (dissoc attributes :id))))
+    (sql/update-values (table-name model-name) ["id = ?" (:id partial-record)] (dissoc partial-record :id))))
 
-(defn destroy-record [model-name record]
+(defn destroy-record
+  "Deletes by (record :id)."
+  [model-name record]
   (sql/with-connection db
     (sql/delete-rows (table-name model-name) ["id = ?" (:id record)])))
 
-(defn destroy-records [model-name attributes]
+(defn destroy-records
+  "Deletes all records matching (-> attributes to-conditions)."
+  [model-name attributes]
   (sql/with-connection db
     (sql/delete-rows (table-name model-name) (to-conditions attributes))))
 

(defn- setup-model-metadata [model-name]
  (dosync (commute all-models-metadata assoc model-name (ref {}))))

(defmacro init-model [& options]
  (let [model-name (last (str-utils/re-split #"\." (name (ns-name *ns*))))]
    (setup-model-metadata model-name)
    (let [optional-forms (defs-from-option-groups model-name options)]
    `(do
      (defn ~'table-name [] (table-name ~model-name))
      (defn ~'get-record [id#]
        (get-record ~model-name id#))
      (defn ~'find-records [attributes#]
        (find-records ~model-name attributes#))
      (defn ~'create [attributes#]
        (create ~model-name attributes#))
      (defn ~'update [attributes#]
        (update ~model-name attributes#))
      (defn ~'destroy-record [record#]
        (destroy-record ~model-name record#))
      (defn ~'validate [record#]
        (clj-record.validation/validate ~model-name record#))
      ~@optional-forms))))

      attributes)]
    (apply vector (str-utils/str-join " AND " parameterized-conditions) values)))

(defn get-record
  "Retrieves record by id, throwing if not found."
  [model-name id]
  (sql/with-connection db
    (sql/with-query-results rows [(format "select * from %s where id = ?" (table-name model-name)) id]
      (if (empty? rows) (throw (IllegalArgumentException. "Record does not exist")))
      (merge {} (first rows)))))

(defn create
  "Inserts a record populated with attributes and returns it."
  [model-name attributes]
  (sql/with-connection db
    (let
      [key-vector (keys attributes)
