Skip to content

Commit

Permalink
Triggers should be dropped before the corresponding functions.
Browse files Browse the repository at this point in the history
 * pyrseas/database.py (Database.diff_map): Add call to
   functions._drop.
 * pyrseas/dbobject/function.py (ProcDict.diff_map): Only mark
   functions for dropping.  (ProcDict._drop): New function to actually
   drop the functions.
  • Loading branch information
jmafc committed Jun 22, 2011
1 parent dd8c151 commit 102bfaa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyrseas/database.py
Expand Up @@ -144,5 +144,6 @@ def diff_map(self, input_map):
stmts.append(self.db.triggers.diff_map(self.ndb.triggers))
stmts.append(self.db.rules.diff_map(self.ndb.rules))
stmts.append(self.db.schemas._drop())
stmts.append(self.db.functions._drop())
stmts.append(self.db.languages._drop())
return [s for s in flatten(stmts)]
16 changes: 14 additions & 2 deletions pyrseas/dbobject/function.py
Expand Up @@ -261,10 +261,22 @@ def diff_map(self, infuncs):
# check existing functions
for (sch, fnc, arg) in self.keys():
func = self[(sch, fnc, arg)]
# if missing, drop them
# if missing, mark it for dropping
if (sch, fnc, arg) not in infuncs:
stmts.append(func.drop())
func.dropped = False

if created:
stmts.insert(0, "SET check_function_bodies = false")
return stmts

def _drop(self):
"""Actually drop the functions
:return: SQL statements
"""
stmts = []
for (sch, fnc, arg) in self.keys():
func = self[(sch, fnc, arg)]
if hasattr(func, 'dropped'):
stmts.append(func.drop())
return stmts

0 comments on commit 102bfaa

Please sign in to comment.