]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/dbconn.py
Merge remote branch 'origin/master' into knownchanges
[dak.git] / daklib / dbconn.py
index 72b072c1f83bd9f07627bbf87f6f104d6c66b5bb..45e000d395fbf104a8331004e7a95451114ba1f6 100755 (executable)
@@ -40,8 +40,10 @@ import traceback
 
 from inspect import getargspec
 
+import sqlalchemy
 from sqlalchemy import create_engine, Table, MetaData
 from sqlalchemy.orm import sessionmaker, mapper, relation
+from sqlalchemy import types as sqltypes
 
 # Don't remove this, we re-export the exceptions to scripts which import us
 from sqlalchemy.exc import *
@@ -55,6 +57,22 @@ from textutils import fix_maintainer
 
 ################################################################################
 
+# Patch in support for the debversion field type so that it works during
+# reflection
+
+class DebVersion(sqltypes.Text):
+    def get_col_spec(self):
+        return "DEBVERSION"
+
+sa_major_version = sqlalchemy.__version__[0:3]
+if sa_major_version == "0.5":
+        from sqlalchemy.databases import postgres
+        postgres.ischema_names['debversion'] = DebVersion
+else:
+        raise Exception("dak isn't ported to SQLA versions != 0.5 yet.  See daklib/dbconn.py")
+
+################################################################################
+
 __all__ = ['IntegrityError', 'SQLAlchemyError']
 
 ################################################################################