Skip to content

Commit

Permalink
Release v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikos410 committed Mar 2, 2021
2 parents d287fd8 + 95227c7 commit 54da59f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defproject evosec/firebird-driver "1.2.1"
(defproject evosec/firebird-driver "1.3.0
:min-lein-version "2.5.0"
:dependencies
[[org.firebirdsql.jdbc/jaybird-jdk18 "3.0.8"]]
[[org.firebirdsql.jdbc/jaybird "4.0.2.java8"]]
:profiles
{:provided
Expand Down
24 changes: 6 additions & 18 deletions src/metabase/driver/firebird.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
firebird->spec
(sql-jdbc.common/handle-additional-options details)))

;; Use "SELECT 1 FROM RDB$DATABASE" instead of "SELECT 1"
(defmethod driver/can-connect? :firebird [driver details]
(let [connection (sql-jdbc.conn/connection-details->spec driver (ssh/include-ssh-tunnel details))]
(= 1 (first (vals (first (jdbc/query connection ["SELECT 1 FROM RDB$DATABASE"])))))))
Expand Down Expand Up @@ -81,22 +80,11 @@
items
(* items (dec page)))]))

;; Firebird stores table names as CHAR(31), so names with < 31 characters get padded with spaces.
;; This confuses everyone, including metabase, so we trim the table names here
(defn post-filtered-trimmed-active-tables
"Alternative implementation of `ISQLDriver/active-tables` best suited for DBs with little or no support for schemas.
Fetch *all* Tables, then filter out ones whose schema is in `excluded-schemas` Clojure-side."
[driver, ^DatabaseMetaData metadata, & [db-name-or-nil]]
(set (for [table (sql-jdbc.sync/post-filtered-active-tables driver metadata db-name-or-nil)]
{:name (str/trim (:name table))
:description (:description table)
:schema (:schema table)})))

(defmethod sql-jdbc.sync/active-tables :firebird [& args]
(apply post-filtered-trimmed-active-tables args))
(apply sql-jdbc.sync/post-filtered-active-tables args))

;; Convert unix time to a timestamp
(defmethod sql.qp/unix-timestamp->timestamp [:firebird :seconds] [_ _ expr]
(defmethod sql.qp/unix-timestamp->honeysql [:firebird :seconds] [_ _ expr]
(hsql/call :DATEADD (hsql/raw "SECOND") expr (hx/cast :TIMESTAMP (hx/literal "01-01-1970 00:00:00"))))

;; Helpers for Date extraction
Expand Down Expand Up @@ -165,12 +153,12 @@
(defmethod sql.qp/date [:firebird :quarter-of-year] [_ _ expr] (hx/+ (hx// (hx/- (hsql/call :extract :MONTH expr) 1) 3) 1))
(defmethod sql.qp/date [:firebird :year] [_ _ expr] (hsql/call :extract :YEAR expr))

(defmethod driver/date-add :firebird [driver dt amount unit]
(defmethod sql.qp/add-interval-honeysql-form :firebird [driver hsql-form amount unit]
(if (= unit :quarter)
(recur driver dt (hx/* amount 3) :month)
(hsql/call :dateadd (hsql/raw (name unit)) amount dt)))
(recur driver hsql-form (hx/* amount 3) :month)
(hsql/call :dateadd (hsql/raw (name unit)) amount hsql-form)))

(defmethod sql.qp/current-datetime-fn :firebird [_]
(defmethod sql.qp/current-datetime-honeysql-form :firebird [_]
(hx/cast :timestamp (hx/literal :now)))

(defmethod driver.common/current-db-time-date-formatters :firebird [_]
Expand Down

0 comments on commit 54da59f

Please sign in to comment.