escape quote characters in quoted identifiers
This commit is contained in:
parent
a25ce4db5d
commit
47cefd0371
2 changed files with 9 additions and 5 deletions
|
|
@ -41,10 +41,10 @@
|
||||||
(def ^:dynamic *allow-dashed-names?* false)
|
(def ^:dynamic *allow-dashed-names?* false)
|
||||||
|
|
||||||
(def ^:private quote-fns
|
(def ^:private quote-fns
|
||||||
{:ansi #(str \" % \")
|
{:ansi #(str \" (string/replace % "\"" "\"\"") \")
|
||||||
:mysql #(str \` % \`)
|
:mysql #(str \` (string/replace % "`" "``") \`)
|
||||||
:sqlserver #(str \[ % \])
|
:sqlserver #(str \[ (string/replace % "]" "]]") \])
|
||||||
:oracle #(str \" % \")})
|
:oracle #(str \" (string/replace % "\"" "\"\"") \")})
|
||||||
|
|
||||||
(def ^:private parameterizers
|
(def ^:private parameterizers
|
||||||
{:postgresql #(str "$" (swap! *all-param-counter* inc))
|
{:postgresql #(str "$" (swap! *all-param-counter* inc))
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,11 @@
|
||||||
3 "3"
|
3 "3"
|
||||||
'foo "foo"
|
'foo "foo"
|
||||||
:foo-bar "foo_bar")
|
:foo-bar "foo_bar")
|
||||||
(is (= (quote-identifier "*" :style :ansi) "*")))
|
(is (= (quote-identifier "*" :style :ansi) "*"))
|
||||||
|
(is (= (quote-identifier "foo\"bar" :style :ansi) "\"foo\"\"bar\""))
|
||||||
|
(is (= (quote-identifier "foo\"bar" :style :oracle) "\"foo\"\"bar\""))
|
||||||
|
(is (= (quote-identifier "foo`bar" :style :mysql) "`foo``bar`"))
|
||||||
|
(is (= (quote-identifier "foo]bar" :style :sqlserver) "[foo]]bar]")))
|
||||||
|
|
||||||
(deftest test-dashed-quote
|
(deftest test-dashed-quote
|
||||||
(binding [*allow-dashed-names?* true]
|
(binding [*allow-dashed-names?* true]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue