Skip to content
This repository was archived by the owner on Sep 1, 2025. It is now read-only.

Commit e620b3c

Browse files
authored
Merge pull request #4 from kumajaya/patch-1
Fix compatibility to Metabase 0.34.x
2 parents aa608c4 + da00671 commit e620b3c

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/metabase/driver/firebird.clj

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[string :as str]]
55
[clojure.java.jdbc :as jdbc]
66
[honeysql.core :as hsql]
7+
[java-time :as t]
78
[metabase.driver :as driver]
89
[metabase.driver.common :as driver.common]
910
[metabase.driver.sql-jdbc
@@ -14,7 +15,8 @@
1415
[metabase.util
1516
[honeysql-extensions :as hx]
1617
[ssh :as ssh]])
17-
(:import [java.sql DatabaseMetaData Time]))
18+
(:import [java.sql DatabaseMetaData Time]
19+
[java.time LocalDate LocalDateTime LocalTime OffsetDateTime OffsetTime ZonedDateTime]))
1820

1921
(driver/register! :firebird, :parent :sql-jdbc)
2022

@@ -184,6 +186,41 @@
184186
[driver [_ field]]
185187
(hsql/call :stddev_samp (sql.qp/->honeysql driver field)))
186188

189+
;; MEGA HACK based on sqlite driver
190+
191+
(defn- zero-time? [t]
192+
(= (t/local-time t) (t/local-time 0)))
193+
194+
(defmethod sql.qp/->honeysql [:firebird LocalDate]
195+
[_ t]
196+
(hx/cast :DATE (t/format "yyyy-MM-dd" t)))
197+
198+
(defmethod sql.qp/->honeysql [:firebird LocalDateTime]
199+
[driver t]
200+
(if (zero-time? t)
201+
(sql.qp/->honeysql driver (t/local-date t))
202+
(hx/cast :TIMESTAMP (t/format "yyyy-MM-dd HH:mm:ss.SSSS" t))))
203+
204+
(defmethod sql.qp/->honeysql [:firebird LocalTime]
205+
[_ t]
206+
(hx/cast :TIME (t/format "HH:mm:ss.SSSS" t)))
207+
208+
(defmethod sql.qp/->honeysql [:firebird OffsetDateTime]
209+
[driver t]
210+
(if (zero-time? t)
211+
(sql.qp/->honeysql driver (t/local-date t))
212+
(hx/cast :TIMESTAMP (t/format "yyyy-MM-dd HH:mm:ss.SSSS" t))))
213+
214+
(defmethod sql.qp/->honeysql [:firebird OffsetTime]
215+
[_ t]
216+
(hx/cast :TIME (t/format "HH:mm:ss.SSSS" t)))
217+
218+
(defmethod sql.qp/->honeysql [:firebird ZonedDateTime]
219+
[driver t]
220+
(if (zero-time? t)
221+
(sql.qp/->honeysql driver (t/local-date t))
222+
(hx/cast :TIMESTAMP (t/format "yyyy-MM-dd HH:mm:ss.SSSS" t))))
223+
187224
(defmethod driver/supports? [:firebird :basic-aggregations] [_ _] true)
188225

189226
(defmethod driver/supports? [:firebird :expression-aggregations] [_ _] true)

0 commit comments

Comments
 (0)