Back

schema (clj)

(source)

function

(schema quoting)
Given a quoting function, return a new quoting function that will process schema-qualified names by quoting each segment: ```clojure (mysql (name :foo.bar)) ;=> `foo.bar` ((schema mysql) (name :foo.bar)) ;=> `foo`.`bar` ```

Examples

next-jdbc
(ns next.jdbc.quoted-test
  "Basic tests for quoting strategies. These are also tested indirectly
  via the next.jdbc.sql tests."
  (:require [clojure.test :refer [deftest are testing]]
            [next.jdbc.quoted :refer [ansi mysql sql-server oracle postgres
                                      schema]]))

(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\"")))