2021-01-30 00:13:05 +00:00
|
|
|
;; copyright (c) 2019-2021 Sean Corfield, all rights reserved
|
2019-04-18 21:15:15 +00:00
|
|
|
|
|
|
|
|
(ns next.jdbc.quoted-test
|
2019-04-19 04:51:58 +00:00
|
|
|
"Basic tests for quoting strategies. These are also tested indirectly
|
|
|
|
|
via the next.jdbc.sql tests."
|
2019-04-21 20:00:03 +00:00
|
|
|
(:require [clojure.test :refer [deftest are testing]]
|
|
|
|
|
[next.jdbc.quoted :refer [ansi mysql sql-server oracle postgres
|
|
|
|
|
schema]]))
|
2019-04-19 01:30:38 +00:00
|
|
|
|
2019-05-29 16:04:21 +00:00
|
|
|
(set! *warn-on-reflection* true)
|
|
|
|
|
|
2019-04-19 01:30:38 +00:00
|
|
|
(deftest basic-quoting
|
|
|
|
|
(are [quote-fn quoted] (= (quote-fn "x") quoted)
|
|
|
|
|
ansi "\"x\""
|
|
|
|
|
mysql "`x`"
|
|
|
|
|
sql-server "[x]"
|
|
|
|
|
oracle "\"x\""
|
|
|
|
|
postgres "\"x\""))
|
2019-04-21 20:00:03 +00:00
|
|
|
|
|
|
|
|
(deftest schema-quoting
|
|
|
|
|
(testing "verify non-schema behavior"
|
|
|
|
|
(are [quote-fn quoted] (= (quote-fn "x.y") quoted)
|
|
|
|
|
ansi "\"x.y\""
|
|
|
|
|
mysql "`x.y`"
|
|
|
|
|
sql-server "[x.y]"
|
|
|
|
|
oracle "\"x.y\""
|
|
|
|
|
postgres "\"x.y\""))
|
|
|
|
|
(testing "verify schema behavior"
|
|
|
|
|
(are [quote-fn quoted] (= ((schema quote-fn) "x.y") quoted)
|
|
|
|
|
ansi "\"x\".\"y\""
|
|
|
|
|
mysql "`x`.`y`"
|
|
|
|
|
sql-server "[x].[y]"
|
|
|
|
|
oracle "\"x\".\"y\""
|
|
|
|
|
postgres "\"x\".\"y\"")))
|