Skip to content

Commit

Permalink
fix #434: improve comment safety check
Browse files Browse the repository at this point in the history
  • Loading branch information
tconbeer committed Jun 8, 2023
1 parent 71cbff1 commit 845c361
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ All notable changes to this project will be documented in this file.
- Relative `exclude` paths defined in `pyproject.toml` files are now evaluated relative to the location of the file, not the current working directory.
Relative paths provided to the `--exclude` option (or env var) are evaluated relative to the current working directory. Files and exclude paths
are now compared as resolved, absolute paths. (Fixes [#431](https://github.com/tconbeer/sqlfmt/issues/431) - thank you [@cmcnicoll](https://github.com/cmcnicoll)!)
- Fixes a bug where a comment like `{#-- comment --#}` would cause a false positive for the
comment safety check. ([#434](https://github.com/tconbeer/sqlfmt/issues/434))

### Formatting Changes
- sqlfmt now supports the `<=>` operator ([#432](https://github.com/tconbeer/sqlfmt/issues/432) - thank you [@kathykwon](https://github.com/kathykwon)!)

## [0.18.3] - 2023-05-31
Expand Down
4 changes: 2 additions & 2 deletions src/sqlfmt/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ def _perform_safety_check(analyzer: Analyzer, raw_query: Query, result: str) ->
comment.token.token for line in result_query.lines for comment in line.comments
]
stripped_raw = "".join(
["".join(c.replace("--", "").replace("#", "").split()) for c in raw_comments]
["".join(c.split()).replace("--", "").replace("#", "") for c in raw_comments]
)
stripped_res = "".join(
["".join(c.replace("--", "").replace("#", "").split()) for c in result_comments]
["".join(c.split()).replace("--", "").replace("#", "") for c in result_comments]
)
try:
assert stripped_raw == stripped_res
Expand Down

0 comments on commit 845c361

Please sign in to comment.