Skip to content

Commit

Permalink
Align and remove option
Browse files Browse the repository at this point in the history
  • Loading branch information
crisptrutski committed Jun 24, 2024
1 parent de56032 commit 96229d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/macaw/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))
3 changes: 1 addition & 2 deletions test/macaw/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 96229d9

Please sign in to comment.