X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=d72f002c522baf0a9869b5ca6724d25dceef746e;hb=113c16c9829699e41dd020920254e87ce499b56a;hp=baa16d0410a8095d54ec4494c58935a13b7fe95d;hpb=be11dfd4b92f3ae0aabdb952afccb8f7a6824f9f;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index baa16d04..d72f002c 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -64,14 +64,24 @@ from dak_exceptions import NoSourceFieldError # Patch in support for the debversion field type so that it works during # reflection -class DebVersion(sqltypes.Text): - """ - Support the debversion type - """ - +try: + # that is for sqlalchemy 0.6 + UserDefinedType = sqltypes.UserDefinedType +except: + # this one for sqlalchemy 0.5 + UserDefinedType = sqltypes.TypeEngine + +class DebVersion(UserDefinedType): def get_col_spec(self): return "DEBVERSION" + def bind_processor(self, dialect): + return None + + # ' = None' is needed for sqlalchemy 0.5: + def result_processor(self, dialect, coltype = None): + return None + sa_major_version = sqlalchemy.__version__[0:3] if sa_major_version in ["0.5", "0.6"]: from sqlalchemy.databases import postgres @@ -81,7 +91,7 @@ else: ################################################################################ -__all__ = ['IntegrityError', 'SQLAlchemyError'] +__all__ = ['IntegrityError', 'SQLAlchemyError', 'DebVersion'] ################################################################################ @@ -2768,7 +2778,6 @@ class DBConn(object): 'binary_acl', 'binary_acl_map', 'build_queue', - 'build_queue_files', 'changelogs_text', 'component', 'config', @@ -2779,7 +2788,6 @@ class DBConn(object): 'files', 'fingerprint', 'keyrings', - 'changes', 'keyring_acl_map', 'location', 'maintainer', @@ -2797,6 +2805,11 @@ class DBConn(object): 'suite', 'uid', 'upload_blocks', + # The following tables have primary keys but sqlalchemy + # version 0.5 fails to reflect them correctly with database + # versions before upgrade #41. + #'changes', + #'build_queue_files', ) tables_no_primary = ( @@ -2810,6 +2823,9 @@ class DBConn(object): 'suite_src_formats', 'suite_build_queue_copy', 'udeb_contents', + # see the comment above + 'changes', + 'build_queue_files', ) views = ( @@ -2836,9 +2852,9 @@ class DBConn(object): 'suite_arch_by_name', ) - # Sqlalchemy fails to reflect the SERIAL type correctly and that - # is why we have to use a workaround. It can be removed as soon - # as we switch to version 0.6. + # Sqlalchemy version 0.5 fails to reflect the SERIAL type + # correctly and that is why we have to use a workaround. It can + # be removed as soon as we switch to version 0.6. for table_name in tables_with_primary: table = Table(table_name, self.db_meta, \ Column('id', Integer, primary_key = True), \