Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #35767 to allow for view creation into specified schema from [ Create a view ] in DBManager #58976

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion python/plugins/db_manager/db_plugins/postgis/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,16 @@ def moveTable(self, table, new_table, new_schema=None):
self._commit()

def createView(self, view, query):
sql = "CREATE VIEW %s AS %s" % (self.quoteId(view), query)
view_name_parts = view.split('.')

if len(view_name_parts) > 2:
# Raise an error when more than one period is used.
raise DbError("Invalid view name: Please use the format 'schema.viewname', or enter only the viewname for the public schema.")
elif len(view_name_parts) == 2: # To allow view creation into specified schema
schema, view_name = view_name_parts
sql = "CREATE VIEW %s AS %s" % (self.quoteId([schema, view_name]), query)
else: # No specific schema specified
sql = "CREATE VIEW %s AS %s" % (self.quoteId(view), query)
self._execute_and_commit(sql)

def createSpatialView(self, view, query):
Expand Down
Loading