[FIX] drop_view_if_exists: simpler and CASCADING implementation for pg 8.3+
OpenERP depends on PostgreSQL 8.3 so we can now use 'IF EXISTS'. It's also necessary to 'CASCADE' the drop, otherwise depending views will prevent the deletion and thus update of the view. Depending views will automatically be updated later and thus re-created, so this is safe. bzr revid: odo@openerp.com-20120227165737-z5fgb6fle9g0cylw
This commit is contained in:
parent
2b2ae48ea9
commit
3e61e9d497
|
@ -20,9 +20,7 @@
|
|||
##############################################################################
|
||||
|
||||
def drop_view_if_exists(cr, viewname):
|
||||
cr.execute("select count(1) from pg_class where relkind=%s and relname=%s", ('v', viewname,))
|
||||
if cr.fetchone()[0]:
|
||||
cr.execute("DROP view %s" % (viewname,))
|
||||
cr.commit()
|
||||
cr.execute("DROP view IF EXISTS %s CASCADE" % (viewname,))
|
||||
cr.commit()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue