                       (name table-name)
                       (if (seq where-cl)
                         (str "where " where-cl) ""))]
-    (with-open [cursor (.rawQuery (.db tagged-db) query nil)]
+    (with-open [^Cursor cursor (.rawQuery (.db tagged-db) query nil)]
       (try (.moveToFirst cursor)
            (get-value-from-cursor cursor 0 type)
            (catch CursorIndexOutOfBoundsException e nil)))))

         (interpose " AND ")
         string/join)))

(defn query
  "Executes SELECT statement against the database and returns a Cursor
  object with the results. `where` argument should be a map of column
  keywords to values."
  [^TaggedDatabase tagged-db table-name where]
  (let [columns (->> (get-in (.schema tagged-db) [:tables table-name :columns])
                     keys
                     (map name)
                     into-array)]
    (.query (.db tagged-db) (name table-name) columns
            (where-clause where) nil nil nil nil)))
(def db-query query)

(defn seq-cursor
  "Turns data from Cursor object into a lazy sequence. Takes database
  argument in order to get schema from it."
  [^TaggedDatabase tagged-db, table-name, ^Cursor cursor]
  (.moveToFirst cursor)
  (let [columns (get-in (.schema tagged-db) [:tables table-name :columns])
        seq-fn (fn seq-fn []
                 (lazy-seq
                  (if (.isAfterLast cursor)
                    (.close cursor)
                    (let [v (reduce-kv
                             (fn [data i [column-name {type :type}]]
                               (assoc data column-name
                                      (get-value-from-cursor cursor i type)))
                             {} (vec columns))]
                      (.moveToNext cursor)
                      (cons v (seq-fn))))))]
    (seq-fn)))

(defn query-seq
  "Executes a SELECT statement against the database and returns the
  result in a sequence. Same as calling `seq-cursor` on `query` output."
  [^TaggedDatabase tagged-db table-name where]
  (seq-cursor tagged-db table-name (db-query tagged-db table-name where)))
(def db-query-seq query-seq)

(defn query-scalar

    Double (.getDouble cur i)
    Byte (.getBlob cur i)))

(defn- qualified-name
  [^Keyword kw]
  (.toString (if (.getNamespace (.sym kw))
               (str (.getNamespace (.sym kw)) "." (.getName (.sym kw)))
               (.getName (.sym kw)))))

(defn- keyval-to-sql
  "Transforms a key-value pair into a proper SQL comparison/assignment
  statement.
