Skip to content

Commit

Permalink
Add cascade to drop for trigger and properly format drop script for f…
Browse files Browse the repository at this point in the history
…unctions/procedures/trigger functions (#476)
  • Loading branch information
samir-puranik authored Sep 1, 2023
1 parent 7e8894d commit 8aac258
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 5 additions & 2 deletions pgsmo/objects/functions/function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,21 @@ def _create_query_data(self) -> dict:

def _delete_query_data(self) -> dict:
""" Provides data input for delete script """
func_def, func_args = self._get_function_definition()
func_args = "(" + func_args + ")"
return {
"name": self.name,
"name": self.name_property,
"nspname": self.schema,
"cascade": self.cascade,
"func_args": func_args,
"conn": self.server.connection.connection
}

def _update_query_data(self) -> dict:
""" Function that returns data for update script """
return {
"data": {
"name": self.name,
"name": self.name_property,
"pronamespace": self.schema,
"arguments": self.arguments,
"lanname": self.language_name,
Expand Down
6 changes: 1 addition & 5 deletions pgsmo/objects/table_objects/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ def prosrc(self):
def description(self):
return self._full_properties["description"]

@property
def cascade(self):
return self._full_properties["cascade"]

@property
def is_enable_trigger(self):
return self._full_properties["is_enable_trigger"]
Expand Down Expand Up @@ -165,7 +161,7 @@ def _delete_query_data(self) -> dict:
"nspname": self.parent.schema,
"relname": self.parent.name
},
"cascade": self.cascade
"cascade": True
}

def _update_query_data(self) -> dict:
Expand Down
2 changes: 0 additions & 2 deletions tests/pgsmo_tests/test_object_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def full_properties(self):
"prosrc": "prosrc",
"custom_tgargs": "custom_tgargs",
"description": "description",
"cascade": "cascade",
"is_enable_trigger": "is_enable_trigger"
}

Expand All @@ -58,7 +57,6 @@ def property_query(self):
"prosrc": "test",
"custom_tgargs": 1,
"description": "test_description",
"cascade": True,
"is_enable_trigger": True
}

Expand Down

0 comments on commit 8aac258

Please sign in to comment.