2025-03-08 01:31:13 +00:00
|
|
|
;; copyright (c) 2019-2025 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."
|
2025-03-18 00:23:12 +00:00
|
|
|
(:require [lazytest.core :refer [defdescribe describe it expect]]
|
2019-04-21 20:00:03 +00:00
|
|
|
[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)
|
|
|
|
|
|
2025-03-18 00:23:12 +00:00
|
|
|
(def ^:private quote-fns [ansi mysql sql-server oracle postgres])
|
2019-04-21 20:00:03 +00:00
|
|
|
|
2025-03-18 00:23:12 +00:00
|
|
|
(defdescribe quoted-functionality
|
|
|
|
|
(describe "base quoting"
|
|
|
|
|
(it "should correctly quote simple names"
|
|
|
|
|
(doseq [[f e] (map vector quote-fns
|
|
|
|
|
["\"x\"" "`x`" "[x]" "\"x\"" "\"x\""])]
|
|
|
|
|
(expect (= (f "x") e)))))
|
|
|
|
|
(describe "dotted name quoting"
|
|
|
|
|
(describe "basic quoting"
|
|
|
|
|
(it "should quote dotted names 'as-is'"
|
|
|
|
|
(doseq [[f e] (map vector quote-fns
|
|
|
|
|
["\"x.y\"" "`x.y`" "[x.y]" "\"x.y\"" "\"x.y\""])]
|
|
|
|
|
(expect (= (f "x.y") e)))))
|
|
|
|
|
(describe "schema quoting"
|
|
|
|
|
(it "should split and quote dotted names with schema"
|
|
|
|
|
(doseq [[f e] (map vector quote-fns
|
|
|
|
|
["\"x\".\"y\"" "`x`.`y`" "[x].[y]" "\"x\".\"y\"" "\"x\".\"y\""])]
|
|
|
|
|
(expect (= ((schema f) "x.y") e)))))))
|