summaryrefslogtreecommitdiff
path: root/adbh.py
diff options
context:
space:
mode:
authorSylvain Thenault <sylvain.thenault@logilab.fr>2008-09-08 20:00:34 +0200
committerSylvain Thenault <sylvain.thenault@logilab.fr>2008-09-08 20:00:34 +0200
commita46eaf83ce840171507100261fa63e95f71d5469 (patch)
tree5f24827643b9f920f4341e8e0fc8469fa0126b30 /adbh.py
parent84a87e513fc6c01601a292e3c600325c15bea1e0 (diff)
downloadlogilab-common-a46eaf83ce840171507100261fa63e95f71d5469.tar.gz
should alter table to properly delete UNIQUE constraints
Diffstat (limited to 'adbh.py')
-rw-r--r--adbh.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/adbh.py b/adbh.py
index 46a0909..872a29e 100644
--- a/adbh.py
+++ b/adbh.py
@@ -257,7 +257,10 @@ INSERT INTO %s VALUES (0);''' % (seq_name, seq_name)
def drop_index(self, cursor, table, column, unique=False):
if self.index_exists(cursor, table, column, unique):
idx = self._index_name(table, column, unique)
- cursor.execute('DROP INDEX %s' % idx)
+ if unique:
+ cursor.execute('ALTER TABLE %s DROP CONSTRAINT %s' % (table, idx))
+ else:
+ cursor.execute('DROP INDEX %s' % idx)
def index_exists(self, cursor, table, column, unique=False):
idx = self._index_name(table, column, unique)