|
41 | 41 | firebird->spec
|
42 | 42 | (sql-jdbc.common/handle-additional-options details)))
|
43 | 43 |
|
44 |
| -;; Use "SELECT 1 FROM RDB$DATABASE" instead of "SELECT 1" |
45 | 44 | (defmethod driver/can-connect? :firebird [driver details]
|
46 | 45 | (let [connection (sql-jdbc.conn/connection-details->spec driver (ssh/include-ssh-tunnel details))]
|
47 | 46 | (= 1 (first (vals (first (jdbc/query connection ["SELECT 1 FROM RDB$DATABASE"])))))))
|
|
81 | 80 | items
|
82 | 81 | (* items (dec page)))]))
|
83 | 82 |
|
84 |
| -;; Firebird stores table names as CHAR(31), so names with < 31 characters get padded with spaces. |
85 |
| -;; This confuses everyone, including metabase, so we trim the table names here |
86 |
| -(defn post-filtered-trimmed-active-tables |
87 |
| - "Alternative implementation of `ISQLDriver/active-tables` best suited for DBs with little or no support for schemas. |
88 |
| - Fetch *all* Tables, then filter out ones whose schema is in `excluded-schemas` Clojure-side." |
89 |
| - [driver, ^DatabaseMetaData metadata, & [db-name-or-nil]] |
90 |
| - (set (for [table (sql-jdbc.sync/post-filtered-active-tables driver metadata db-name-or-nil)] |
91 |
| - {:name (str/trim (:name table)) |
92 |
| - :description (:description table) |
93 |
| - :schema (:schema table)}))) |
94 |
| - |
95 | 83 | (defmethod sql-jdbc.sync/active-tables :firebird [& args]
|
96 |
| - (apply post-filtered-trimmed-active-tables args)) |
| 84 | + (apply sql-jdbc.sync/post-filtered-active-tables args)) |
97 | 85 |
|
98 | 86 | ;; Convert unix time to a timestamp
|
99 |
| -(defmethod sql.qp/unix-timestamp->timestamp [:firebird :seconds] [_ _ expr] |
| 87 | +(defmethod sql.qp/unix-timestamp->honeysql [:firebird :seconds] [_ _ expr] |
100 | 88 | (hsql/call :DATEADD (hsql/raw "SECOND") expr (hx/cast :TIMESTAMP (hx/literal "01-01-1970 00:00:00"))))
|
101 | 89 |
|
102 | 90 | ;; Helpers for Date extraction
|
|
165 | 153 | (defmethod sql.qp/date [:firebird :quarter-of-year] [_ _ expr] (hx/+ (hx// (hx/- (hsql/call :extract :MONTH expr) 1) 3) 1))
|
166 | 154 | (defmethod sql.qp/date [:firebird :year] [_ _ expr] (hsql/call :extract :YEAR expr))
|
167 | 155 |
|
168 |
| -(defmethod driver/date-add :firebird [driver dt amount unit] |
| 156 | +(defmethod sql.qp/add-interval-honeysql-form :firebird [driver hsql-form amount unit] |
169 | 157 | (if (= unit :quarter)
|
170 |
| - (recur driver dt (hx/* amount 3) :month) |
171 |
| - (hsql/call :dateadd (hsql/raw (name unit)) amount dt))) |
| 158 | + (recur driver hsql-form (hx/* amount 3) :month) |
| 159 | + (hsql/call :dateadd (hsql/raw (name unit)) amount hsql-form))) |
172 | 160 |
|
173 |
| -(defmethod sql.qp/current-datetime-fn :firebird [_] |
| 161 | +(defmethod sql.qp/current-datetime-honeysql-form :firebird [_] |
174 | 162 | (hx/cast :timestamp (hx/literal :now)))
|
175 | 163 |
|
176 | 164 | (defmethod driver.common/current-db-time-date-formatters :firebird [_]
|
|
0 commit comments