                       :entity datom})))
 
           ;; Check for violated :db/unique constraint between datoms.
-          (when (ds/unique? (schema db) a)
+          (when (ds/unique? schema a)
             (let [key [nil a v]]
               (when-let [other (get unique-datoms key)]
                 (raise "Cannot add " datom " and " other " because together they violate unique constraint"

  ;; TODO: use q for searching?  Have q use this for searching for a single pattern?
  (<eavt [db pattern]
    (let [[e a v] pattern
          v (and v (ds/->SQLite schema a v))] ;; We assume e and a are always given.
      (go-pair
        (->>
          {:select [:e :a :v :tx [1 :added]] ;; TODO: generalize columns.
           :from [:all_datoms]
           :where (cons :and (map #(vector := %1 %2) [:e :a :v] (take-while (comp not nil?) [e a v])))} ;; Must drop nils.
          (sql/format)

          (s/all-rows (:sqlite-connection db))

  {:pre [(db? db) (report? report)]}
  (go-pair
    (let [initial-report report
          {tx :tx}       report
          schema         (schema db)]
      (loop [report initial-report
             es (:entities initial-report)]
        (let [[[op e a v :as entity] & entities] es]
