Skip to content

Commit

Permalink
Add IF EXISTS clause to DROP VIEW statements in order to prevent erro…
Browse files Browse the repository at this point in the history
…rs when non-existing views will be dropped in an Alembic version
  • Loading branch information
henryhueske committed Mar 7, 2024
1 parent 99e1e31 commit 0705217
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/

# End of https://www.toptal.com/developers/gitignore/api/python,macos

Expand Down
3 changes: 3 additions & 0 deletions src/databricks/sqlalchemy/dialect/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def visit_drop_table(self, drop, **kw):

return text + self.preparer.format_table(drop.element)

def visit_drop_view(self, drop, **kw):
return "\nDROP VIEW IF EXISTS " + self.preparer.format_table(drop.element)


@compiles(ColumnComment, "databricks")
def visit_column_comment(
Expand Down

0 comments on commit 0705217

Please sign in to comment.