Liking cljdoc? Tell your friends :D

metabase.driver.sql-jdbc.execute

Code related to actually running a SQL query against a JDBC database (including setting the session timezone when appropriate), and for properly encoding/decoding types going in and out of the database.

Code related to actually running a SQL query against a JDBC database (including setting the session timezone when
appropriate), and for properly encoding/decoding types going in and out of the database.
raw docstring

do-with-try-catchclj

(do-with-try-catch f)

Tries to run the function f, catching and printing exception chains if SQLException is thrown, and rethrowing the exception as an Exception with a nicely formatted error message.

Tries to run the function `f`, catching and printing exception chains if SQLException is thrown,
and rethrowing the exception as an Exception with a nicely formatted error message.
sourceraw docstring

execute-queryclj

(execute-query driver {settings :settings query :native :as outer-query})

Process and run a native (raw SQL) QUERY.

Process and run a native (raw SQL) QUERY.
sourceraw docstring

parse-date-as-stringclj

(parse-date-as-string cal rs i)

Most databases will never invoke this code. It's possible with SQLite to get here if the timestamp was stored without milliseconds. Currently the SQLite JDBC driver will throw an exception even though the SQLite datetime functions will return datetimes that don't include milliseconds. This attempts to parse that datetime in Clojure land

Most databases will never invoke this code. It's possible with SQLite to get here if the timestamp was stored
without milliseconds. Currently the SQLite JDBC driver will throw an exception even though the SQLite datetime
functions will return datetimes that don't include milliseconds. This attempts to parse that datetime in Clojure
land
sourceraw docstring

read-columncljmultimethod

(read-column driver calendar resultset resultset-metadata i)

Read a single value from a single column in a single row from the JDBC ResultSet of a Metabase query. Normal implementations call an appropriate method on ResultSet to retrieve this value, such as (.getObject resultset i). (i is the index of the column whose value you should retrieve.)

This method provides the opportunity to customize behavior for the way a driver returns or formats results of certain types -- this method dispatches on both driver and column type. For example, the MySQL/MariaDB driver provides a custom implementation for Types/TIME to work around questionable Timezone support.

If set, the report timezone active at the time the query was ran will be passed as a Calendar; otherwise this value will be nil -- be sure to check before doing anything crazy with it.

Read a single value from a single column in a single row from the JDBC ResultSet of a Metabase query. Normal
implementations call an appropriate method on `ResultSet` to retrieve this value, such as `(.getObject resultset
i)`. (`i` is the index of the column whose value you should retrieve.)

This method provides the opportunity to customize behavior for the way a driver returns or formats results of
certain types -- this method dispatches on both driver and column type. For example, the MySQL/MariaDB driver
provides a custom implementation for `Types/TIME` to work around questionable Timezone support.

If set, the report timezone active at the time the query was ran will be passed as a Calendar; otherwise this value
will be `nil` -- be sure to check before doing anything crazy with it.
sourceraw docstring

read-columnscljmultimethod

(read-columns driver calendar)

Return a function that will be used to read a row from a ResultSet, passed to Clojure JDBC as the :read-columns argument. Returned function should take three args: resultset, resultset-metadata, and indexes, and return a sequence of results. Default implementation calls read-column and passes results to jdbc/result-set-read-column.

This method provides a low-level opportunity to transform the shape of the results as a whole, e.g. by removing extraneous columns from the results or adding missing ones. If you only want to override behavior for a single type (e.g., convert bits to booleans), implement read-column instead.

Return a function that will be used to read a row from a ResultSet, passed to Clojure JDBC as the `:read-columns`
argument. Returned function should take three args: `resultset`, `resultset-metadata`, and `indexes`, and return a
sequence of results. Default implementation calls `read-column` and passes results to `jdbc/result-set-read-column`.

This method provides a low-level opportunity to transform the shape of the results as a whole, e.g. by removing
extraneous columns from the results or adding missing ones. If you only want to override behavior for a single
type (e.g., convert bits to booleans), implement `read-column` instead.
sourceraw docstring

set-timezone-sqlcljmultimethod

(set-timezone-sql driver)

Return a format string containing a SQL statement to be used to set the timezone for the current transaction. The %s will be replaced with a string literal for a timezone, e.g. US/Pacific.

"SET @@session.timezone = %s;"

Return a format string containing a SQL statement to be used to set the timezone for the current transaction.
The `%s` will be replaced with a string literal for a timezone, e.g. `US/Pacific.`

  "SET @@session.timezone = %s;"
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close