Skip to content

Commit

Permalink
removing with when no dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
bbeat2782 committed Jun 27, 2023
1 parent ece54c1 commit 6dbf951
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* [Doc] Document --persist-replace in API section (#539)
* [Fix] Fixed CI issue by updating `invalid_connection_string_duckdb` in `test_magic.py` (#631)
* [Fix] Refactored `ResultSet` to lazy loading (#470)
* [Fix] Removed `WITH` when a snippet does not have a dependency (#657)

## 0.7.9 (2023-06-19)

Expand Down
2 changes: 2 additions & 0 deletions src/sql/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def __str__(self) -> str:
template = (
with_clause_template_backtick if is_use_backtick else with_clause_template
)
if len(with_all) == 0:
return self._query.strip()
return template.render(
query=self._query,
saved=self._store._data,
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_magic_cte.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_snippets_delete(ip, capsys):
)
result = ip.run_cell("%sqlrender final").result
expected = (
"WITH\n\n SELECT o.order_id, customers.name, "
"SELECT o.order_id, customers.name, "
"o.order_value\n "
"FROM another_orders o\n INNER JOIN customers "
"ON o.customer_id=customers.customer_id"
Expand Down

0 comments on commit 6dbf951

Please sign in to comment.