 (defn- date
   "Apply truncation / extraction to a date field or value for SQLite.
    See also the [SQLite Date and Time Functions Reference](http://www.sqlite.org/lang_datefunc.html)."
-  [_ unit expr]
+  [unit expr]
   ;; Convert Timestamps to ISO 8601 strings before passing to SQLite, otherwise they don't seem to work correctly
   (let [v (if (instance? java.sql.Timestamp expr)
             (kx/literal (u/date->iso-8601 expr))
             expr)]
     (case unit
       :default         (->datetime v)
+      :second          (->datetime (strftime "%Y-%m-%d %H:%M:%S" v))
       :minute          (->datetime (strftime "%Y-%m-%d %H:%M" v))
       :minute-of-hour  (kx/->integer (strftime "%M" v))
       :hour            (->datetime (strftime "%Y-%m-%d %H:00" v))

(u/strict-extend SQLiteDriver
  driver/IDriver
  (merge (sql/IDriverSQLDefaultsMixin)
         {:date-interval  date-interval
          :details-fields (constantly [{:name         "db"
                                        :display-name "Filename"
                                        :placeholder  "/home/camsaul/toucan_sightings.sqlite 😋"

          :connection-details->spec  (fn [_ details]
                                       (kdb/sqlite3 details))
          :current-datetime-fn       (constantly (k/raw "DATETIME('now')"))
          :date                      (u/drop-first-arg date)
          :string-length-fn          (constantly :LENGTH)
          :unix-timestamp->timestamp (u/drop-first-arg unix-timestamp->timestamp)}))

(driver/register-driver! :sqlite (SQLiteDriver.))
