X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=75d271bd39d1cbff799fa9b02d68cfa8345b6f5d;hb=ba4c35e339b908e5a632a2974a9658ecc38b21be;hp=72b072c1f83bd9f07627bbf87f6f104d6c66b5bb;hpb=2cd56ae18c977d13b8676ca60ef9fe85856e71f2;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 72b072c1..75d271bd 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -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'] ################################################################################ @@ -2534,7 +2552,8 @@ class DBConn(Singleton): primaryjoin=(self.tbl_src_uploaders.c.maintainer==self.tbl_maintainer.c.id)))) mapper(Suite, self.tbl_suite, - properties = dict(suite_id = self.tbl_suite.c.id)) + properties = dict(suite_id = self.tbl_suite.c.id, + policy_queue = relation(Queue))) mapper(SuiteArchitecture, self.tbl_suite_architectures, properties = dict(suite_id = self.tbl_suite_architectures.c.suite,