Skip to content
Snippets Groups Projects
Commit ced090aa authored by Cam Saül's avatar Cam Saül
Browse files

Cleanup backported from nested-queries branch :shower:

parent 2f9bc079
No related branches found
No related tags found
No related merge requests found
......@@ -18,9 +18,6 @@
;; but not Rasta (all-users)
(defn- api-call-was-successful? {:style/indent 0} [response]
(when (and (string? response)
(not= response "You don't have permissions to do that."))
(println "RESPONSE:" response)) ; DEBUG
(and (not= response "You don't have permissions to do that.")
(not= response "Unauthenticated")))
......
......@@ -129,7 +129,7 @@
:table_id (u/get-id table)
:dataset_query {:database (u/get-id db)
:type "native"
:query (format "SELECT count(*) FROM \"%s\";" (:name table))}}))
:native {:query (format "SELECT count(*) FROM \"%s\";" (:name table))}}}))
(def ^:dynamic *card:db1-count-of-venues*)
......
......@@ -105,3 +105,53 @@
(qputil/query-hash {:database 2
:type "native"
:native {:query "SELECT pg_sleep(15), 2 AS two"}})))
;;; ------------------------------------------------------------ Tests for get-normalized and get-in-normalized ------------------------------------------------------------
(expect 2 (qputil/get-normalized {"num_toucans" 2} :num-toucans))
(expect 2 (qputil/get-normalized {"NUM_TOUCANS" 2} :num-toucans))
(expect 2 (qputil/get-normalized {"num-toucans" 2} :num-toucans))
(expect 2 (qputil/get-normalized {:num_toucans 2} :num-toucans))
(expect 2 (qputil/get-normalized {:NUM_TOUCANS 2} :num-toucans))
(expect 2 (qputil/get-normalized {:num-toucans 2} :num-toucans))
(expect
nil
(qputil/get-normalized nil :num-toucans))
(expect 2 (qputil/get-in-normalized {"BIRDS" {"NUM_TOUCANS" 2}} [:birds :num-toucans]))
(expect 2 (qputil/get-in-normalized {"birds" {"num_toucans" 2}} [:birds :num-toucans]))
(expect 2 (qputil/get-in-normalized {"birds" {"num-toucans" 2}} [:birds :num-toucans]))
(expect 2 (qputil/get-in-normalized {:BIRDS {:NUM_TOUCANS 2}} [:birds :num-toucans]))
(expect 2 (qputil/get-in-normalized {:birds {:num_toucans 2}} [:birds :num-toucans]))
(expect 2 (qputil/get-in-normalized {:birds {:num-toucans 2}} [:birds :num-toucans]))
(expect
2
(qputil/get-in-normalized {:num-toucans 2} [:num-toucans]))
(expect
nil
(qputil/get-in-normalized nil [:birds :num-toucans]))
(expect
10
(qputil/get-in-normalized
{"dataset_query" {"query" {"source_table" 10}}}
[:dataset-query :query :source-table]))
(expect {} (qputil/dissoc-normalized {"NUM_TOUCANS" 3} :num-toucans))
(expect {} (qputil/dissoc-normalized {"num_toucans" 3} :num-toucans))
(expect {} (qputil/dissoc-normalized {"num-toucans" 3} :num-toucans))
(expect {} (qputil/dissoc-normalized {:NUM_TOUCANS 3} :num-toucans))
(expect {} (qputil/dissoc-normalized {:num_toucans 3} :num-toucans))
(expect {} (qputil/dissoc-normalized {:num-toucans 3} :num-toucans))
(expect
{}
(qputil/dissoc-normalized {:num-toucans 3, "NUM_TOUCANS" 3, "num_toucans" 3} :num-toucans))
(expect
nil
(qputil/dissoc-normalized nil :num-toucans))
......@@ -120,7 +120,12 @@
`(run-query* (query ~table ~@forms)))
(defn format-name [nm]
(defn format-name
"Format a SQL schema, table, or field identifier in the correct way for the current database by calling the
driver's implementation of `format-name`.
(Most databases use the default implementation of `identity`; H2 uses `clojure.string/upper-case`.)
This function DOES NOT quote the identifier."
[nm]
(i/format-name *driver* (name nm)))
(defn- get-table-id-or-explode [db-id table-name]
......
......@@ -70,7 +70,6 @@
{:pre [(string? email) (string? first) (string? last) (string? password) (m/boolean? superuser) (m/boolean? active)]}
(wait-for-initiailization)
(or (User :email email)
(println "Creating test user:" email) ; DEBUG
(db/insert! User
:email email
:first_name first
......@@ -139,7 +138,6 @@
(when-not (= status-code 401)
(throw e))
;; If we got a 401 unauthenticated clear the tokens cache + recur
(printf "Got 401 (Unauthenticated) for %s. Clearing cached auth tokens and retrying request.\n" username) ; DEBUG
(reset! tokens {})
(apply client-fn username args)))))
......
......@@ -16,8 +16,8 @@ log4j.appender.file.layout.ConversionPattern=%d [%t] %-5p%c - %m%n
# customizations to logging by package
log4j.logger.com.mchange=ERROR
log4j.logger.org.eclipse.jetty.server.HttpChannel=ERROR
log4j.logger.metabase=ERROR
log4j.logger.metabase.middleware=INFO
log4j.logger.metabase.test-setup=INFO
log4j.logger.metabase.test.data.datasets=INFO
log4j.logger.metabase.util.encryption=INFO
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment