             :when (contains? data-map col)]
       (let [value (get data-map col)]
         (condp = type
-          Integer (.put cv (name col) ^Integer value)
+          Integer (.put cv (name col) ^Integer (int value))
           Long (.put cv (name col) ^Long value)
           Double (.put cv (name col) ^Double value)
           String (.put cv (name col) ^String value)

  (let [columns (get-in (.schema tagged-db) [:tables table-name :columns])
        seq-fn (fn seq-fn []
                 (lazy-seq
                  (when-not (.isAfterLast cursor)
                    (let [v (reduce-kv
                             (fn [data i [column-name {type :type}]]
                               (assoc data column-name

;; A wrapper around SQLiteDatabase to keep database and its schema
;; together.
;;
(deftype TaggedDatabase [^SQLiteDatabase db, schema])

(defn get-database
  "Returns SQLiteDatabase instance for the given schema. Access-mode can be
  either `:read` or `:write`."
  {:forms '([context schema access-mode])}
  ([schema access-mode]
   (println "Two-argument version is deprecated. Please use (get-database context schema access-mode)")
   (get-database context schema mode))
  ([context schema access-mode]
   {:pre [(#{:read :write} access-mode)]}
   (let [helper (create-helper context schema)]
     (TaggedDatabase. (case access-mode
                        :read (.getReadableDatabase helper)
                        :write (.getWritableDatabase helper))
                      schema))))

;; ### Data-SQL transformers

