Skip to content

Commit d3dc3f2

Browse files
authored
#77 Replace deprecated connection-with-timezone (#82)
1 parent 75a12f0 commit d3dc3f2

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

doc/changes/changes_1.0.8.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ This release adapts the driver to Metabase v0.50.36.
88

99
The driver now supports Metabase feature `:describe-fks`. This allows Metabase to retrieve metadata about Foreign Key Constraints from Exasol.
1010

11+
Also the driver now replaces the deprecated method `sql-jdbc.execute/connection-with-timezone` with `sql-jdbc.execute/do-with-connection-with-options`. This will allow using the driver with later Metabase versions and avoids the following warning in the Metabase log:
12+
13+
```
14+
WARN sql-jdbc.execute :: connection-with-timezone is deprecated in Metabase 0.47.0. Implement do-with-connection-with-options instead.
15+
```
16+
1117
## Features
1218

1319
* #78: Upgraded to Metabase v0.50.36
20+
21+
## Bugfixes
22+
23+
* #77: Replace deprecated method `sql-jdbc.execute/connection-with-timezone`

src/metabase/driver/exasol.clj

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -157,25 +157,21 @@
157157
(.execute stmt set-timezone-sql)
158158
(log/tracef "Successfully set timezone for Exasol to %s using statement %s" timezone-id set-timezone-sql)))))
159159

160-
;; Same as default implementation but without calling the unsupported setHoldability() method
161-
(defmethod sql-jdbc.execute/connection-with-timezone :exasol
162-
[driver database ^String timezone-id]
163-
(let [conn (.getConnection (sql-jdbc.execute/datasource-with-diagnostic-info! driver database))]
164-
(try
165-
(sql-jdbc.execute/set-best-transaction-level! driver conn)
166-
(set-time-zone! conn timezone-id)
167-
(try
168-
(.setReadOnly conn true)
169-
(catch Throwable e
170-
(log/warn e (trs "Error setting connection to read-only"))))
171-
(try
172-
(.setAutoCommit conn false)
173-
(catch Throwable e
174-
(log/warn e (trs "Error setting connection to autoCommit false"))))
175-
conn
176-
(catch Throwable e
177-
(.close conn)
178-
(throw e)))))
160+
(defmethod sql-jdbc.execute/do-with-connection-with-options :exasol
161+
[driver db-or-id-or-spec {:keys [session-timezone], :as options} f]
162+
(sql-jdbc.execute/do-with-resolved-connection driver db-or-id-or-spec options
163+
(fn [^java.sql.Connection conn]
164+
(sql-jdbc.execute/set-best-transaction-level! driver conn)
165+
(set-time-zone! conn session-timezone)
166+
(try
167+
(.setReadOnly conn true)
168+
(catch Throwable e
169+
(log/warn e (trs "Error setting connection to read-only"))))
170+
(try
171+
(.setAutoCommit conn false)
172+
(catch Throwable e
173+
(log/warn e (trs "Error setting connection to autoCommit false"))))
174+
(f conn))))
179175

180176
(defn- trunc-date
181177
"Truncate a date, e.g.:

0 commit comments

Comments
 (0)