diff --git a/doc/getting-started.md b/doc/getting-started.md index a74918f..cc15093 100644 --- a/doc/getting-started.md +++ b/doc/getting-started.md @@ -339,6 +339,8 @@ globally via the `set-dialect!` function. ;; and reset back to the default of :ansi (sql/set-dialect! :ansi) ;;=> nil +;; which also resets the quoting default (back to nil) +;; so only unusual entity names get quoted: (sql/format '{select (id) from (table)} {:quoted true}) ;;=> ["SELECT \"id\" FROM \"table\""] ``` diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index 2cd7324..4d8c720 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -1563,16 +1563,17 @@ Can be: `:ansi` (the default), `:mysql`, `:oracle`, or `:sqlserver`. Can optionally accept `:quoted true` (or `:quoted false`) to set the - default global quoting strategy. Note that calling `set-options!` can - override this default. + default global quoting strategy. Without `:quoted`, the default global + quoting strategy will be reset (only quoting unusual entity names). + + Note that calling `set-options!` can override this default. Dialects are always applied to the base order to create the current order." - [dialect & {:as opts}] + [dialect & {:keys [quoted]}] (reset! default-dialect (get @dialects (check-dialect dialect))) (when-let [f (:clause-order-fn @default-dialect)] (reset! current-clause-order (f @base-clause-order))) - (when (contains? opts :quoted) - (reset! default-quoted (:quoted opts)))) + (reset! default-quoted quoted)) (defn set-options! "Set default values for any or all of the following options: