summaryrefslogtreecommitdiff
path: root/src/mailman/database
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/database')
-rw-r--r--src/mailman/database/model.py2
-rw-r--r--src/mailman/database/postgresql.py9
-rw-r--r--src/mailman/database/types.py3
3 files changed, 7 insertions, 7 deletions
diff --git a/src/mailman/database/model.py b/src/mailman/database/model.py
index 06705dfe9..b65d7d5eb 100644
--- a/src/mailman/database/model.py
+++ b/src/mailman/database/model.py
@@ -49,7 +49,7 @@ class ModelMeta:
for table in reversed(Model.metadata.sorted_tables):
connection.execute(table.delete())
except:
- transaction.abort()
+ transaction.rollback()
raise
else:
transaction.commit()
diff --git a/src/mailman/database/postgresql.py b/src/mailman/database/postgresql.py
index 59fff0865..ca1068302 100644
--- a/src/mailman/database/postgresql.py
+++ b/src/mailman/database/postgresql.py
@@ -40,15 +40,14 @@ class PostgreSQLDatabase(SABaseDatabase):
restart from zero for new tests.
"""
super(PostgreSQLDatabase, self)._post_reset(store)
- from mailman.database.model import ModelMeta
- classes = sorted(ModelMeta._class_registry,
- key=attrgetter('__storm_table__'))
+ from mailman.database.model import Model
+ tables = reversed(Model.metadata.sorted_tables)
# Recipe adapted from
# http://stackoverflow.com/questions/544791/
# django-postgresql-how-to-reset-primary-key
- for model_class in classes:
+ for table in tables:
store.execute("""\
SELECT setval('"{0}_id_seq"', coalesce(max("id"), 1),
max("id") IS NOT null)
FROM "{0}";
- """.format(model_class.__storm_table__))
+ """.format(table))
diff --git a/src/mailman/database/types.py b/src/mailman/database/types.py
index 641e065ba..eec6df6d5 100644
--- a/src/mailman/database/types.py
+++ b/src/mailman/database/types.py
@@ -30,6 +30,7 @@ import uuid
from sqlalchemy import Integer
from sqlalchemy.types import TypeDecorator, CHAR
+from sqlalchemy.dialects import postgresql
@@ -68,7 +69,7 @@ class UUID(TypeDecorator):
def load_dialect_impl(self, dialect):
if dialect.name == 'postgresql':
- return dialect.type_descriptor(UUID())
+ return dialect.type_descriptor(postgresql.UUID())
else:
return dialect.type_descriptor(CHAR(32))