test xtdb dialect and quoted columns
Signed-off-by: Sean Corfield <sean@corfield.org>
This commit is contained in:
parent
f4d212ae18
commit
ee53c54255
1 changed files with 17 additions and 1 deletions
|
|
@ -1,12 +1,28 @@
|
||||||
;; copyright (c) 2020-2024 sean corfield, all rights reserved
|
;; copyright (c) 2020-2024 sean corfield, all rights reserved
|
||||||
|
|
||||||
(ns honey.sql.xtdb-test
|
(ns honey.sql.xtdb-test
|
||||||
(:require [clojure.test :refer [deftest is testing]]
|
(:require [clojure.test :refer [deftest is testing use-fixtures]]
|
||||||
[honey.sql :as sql]
|
[honey.sql :as sql]
|
||||||
[honey.sql.helpers :as h
|
[honey.sql.helpers :as h
|
||||||
:refer [select exclude rename from where]]))
|
:refer [select exclude rename from where]]))
|
||||||
|
|
||||||
|
(use-fixtures :once (fn [t]
|
||||||
|
(try
|
||||||
|
(sql/set-dialect! :xtdb)
|
||||||
|
(t)
|
||||||
|
(finally
|
||||||
|
(sql/set-dialect! :ansi)))))
|
||||||
|
|
||||||
(deftest select-tests
|
(deftest select-tests
|
||||||
|
(testing "qualified columns"
|
||||||
|
(is (= ["SELECT \"foo\".\"bar\", \"baz/quux\""]
|
||||||
|
(sql/format {:select [:foo.bar :baz/quux]} {:quoted true})))
|
||||||
|
(is (= ["SELECT \"foo\".\"bar\", \"baz/quux\""]
|
||||||
|
(sql/format {:select [:foo.bar :baz/quux]} {:dialect :xtdb})))
|
||||||
|
(is (= ["SELECT foo.bar, \"baz/quux\""]
|
||||||
|
(sql/format {:select [:foo.bar :baz/quux]})))
|
||||||
|
(is (= ["SELECT foo.bar, baz/quux"]
|
||||||
|
(sql/format {:select [:foo.bar :baz/quux]} {:quoted false}))))
|
||||||
(testing "select, exclude, rename"
|
(testing "select, exclude, rename"
|
||||||
(is (= ["SELECT * EXCLUDE _id RENAME value AS foo_value FROM foo"]
|
(is (= ["SELECT * EXCLUDE _id RENAME value AS foo_value FROM foo"]
|
||||||
(sql/format (-> (select :*) (exclude :_id) (rename [:value :foo_value])
|
(sql/format (-> (select :*) (exclude :_id) (rename [:value :foo_value])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue