Skip to content
Snippets Groups Projects
Unverified Commit 34d626ae authored by Cam Saul's avatar Cam Saul
Browse files

Add new IDriver default-to-case-sensitive? method

parent 2d34684f
Branches
Tags
No related merge requests found
......@@ -212,7 +212,12 @@
returned in any given order.")
(current-db-time ^org.joda.time.DateTime [this ^DatabaseInstance database]
"Returns the current time and timezone from the perspective of `DATABASE`."))
"Returns the current time and timezone from the perspective of `DATABASE`.")
(default-to-case-sensitive? ^Boolean [this]
"Should this driver default to case-sensitive string search filter clauses (e.g. `starts-with` or `contains`)? The
default is `true` since that was the behavior of all drivers with the exception of GA before `0.29.0` when we
introduced case-insensitive string search filters as an option."))
(def IDriverDefaultsMixin
"Default implementations of `IDriver` methods marked *OPTIONAL*."
......@@ -228,7 +233,8 @@
(throw
(NoSuchMethodException.
(str (name driver) " does not implement table-rows-seq."))))
:current-db-time (constantly nil)})
:current-db-time (constantly nil)
:default-to-case-sensitive? (constantly true)})
;;; ## CONFIG
......
......@@ -60,7 +60,6 @@
(try (vec (POST (details->url details-with-tunnel "/druid/v2"), :body query))
(catch Throwable e
;; try to extract the error
(println "(u/pprint-to-str 'red e):" (u/pprint-to-str 'red (or (ex-data e) e))) ; NOCOMMIT
(let [message (or (u/ignore-exceptions
(:error (json/parse-string (:body (:object (ex-data e))) keyword)))
(.getMessage e))]
......
......@@ -263,7 +263,8 @@
:process-query-in-context (u/drop-first-arg process-query-in-context)
:mbql->native (u/drop-first-arg qp/mbql->native)
:table-rows-seq (u/drop-first-arg table-rows-seq)
:humanize-connection-error-message (u/drop-first-arg humanize-connection-error-message)}))
:humanize-connection-error-message (u/drop-first-arg humanize-connection-error-message)
:default-to-case-sensitive? (constantly false)}))
(defn -init-driver
"Register the Google Analytics driver"
......
......@@ -189,7 +189,6 @@
(defn mbql->native
"Transpile MBQL query into parameters required for a Google Analytics request."
[{:keys [query], :as raw}]
(println "(u/pprint-to-str 'blue query):" (u/pprint-to-str 'blue query)) ; NOCOMMIT
{:query (merge (handle-source-table query)
(handle-breakout query)
(handle-filter:interval query)
......
......@@ -4,6 +4,7 @@
(:refer-clojure :exclude [< <= > >= = != and or not filter count distinct sum min max + - / *])
(:require [clojure.core :as core]
[clojure.tools.logging :as log]
[metabase.driver :as driver]
[metabase.query-processor
[interface :as i]
[util :as qputil]]
......@@ -294,9 +295,13 @@
"String search filter clauses: `contains`, `starts-with`, and `ends-with`. First shipped in `0.11.0` (before initial
public release) but only supported case-sensitive searches. In `0.29.0` support for case-insensitive searches was
added. For backwards-compatibility, and to avoid possible performance implications, case-sensitive is the default
option if no `options-maps` is specified."
option if no `options-maps` is specified for all drivers except GA. Whether we should default to case-sensitive can
be specified by the `IDriver` method `default-to-case-sensitive?`."
([filter-type f s]
(string-filter filter-type f s {:case-sensitive true}))
(string-filter filter-type f s {:case-sensitive (if i/*driver*
(driver/default-to-case-sensitive? i/*driver*)
;; if *driver* isn't bound then just assume `true`
true)}))
([filter-type f s options-map]
(i/strict-map->StringFilter
{:filter-type filter-type
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment