diff --git a/src/macaw/core.clj b/src/macaw/core.clj index a0c2dfc..6afdab3 100644 --- a/src/macaw/core.clj +++ b/src/macaw/core.clj @@ -62,14 +62,14 @@ ;; We need to pre-sanitize the SQL before its analyzed so that the AST token positions match up correctly. ;; Currently, we use a more complex and expensive sanitization method, so that it's reversible. ;; If we decide that it's OK to normalize whitespace etc. during replacement, then we can use the same helper. - (let [sql' (escape-keywords (str/replace sql #"(?m)^\n" " \n") (:non-reserved-words opts)) - opts' (select-keys opts [:case-insensitive :quotes-preserve-case? :allow-unused?]) + (let [sql' (escape-keywords (str/replace sql #"(?m)^\n" " \n") (:non-reserved-words opts)) + opts' (select-keys opts [:case-insensitive :quotes-preserve-case? :allow-unused?]) renames' (walk/prewalk (fn [x] (if (string? x) (escape-keywords x (:non-reserved-words opts)) x)) renames) - parsed (parsed-query sql' opts)] + parsed (parsed-query sql' opts)] (-> (rewrite/replace-names sql' parsed renames' opts') (str/replace #"(?m)^ \n" "\n") (unescape-keywords (:non-reserved-words opts))))) diff --git a/test/macaw/core_test.clj b/test/macaw/core_test.clj index cf489c9..b83e901 100644 --- a/test/macaw/core_test.clj +++ b/test/macaw/core_test.clj @@ -601,8 +601,7 @@ from foo") (m/replace-names "SELECT final FROM x" {:tables {{:table "x"} "final"} :columns {{:table "x" :column "final"} "y"}} - {:non-reserved-words [:final] - :allow-unused? true}))))) + {:non-reserved-words [:final]}))))) (comment (require 'hashp.core)