# 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
################################################################################
-__all__ = ['IntegrityError', 'SQLAlchemyError']
+__all__ = ['IntegrityError', 'SQLAlchemyError', 'DebVersion']
################################################################################
################################################################################
class Fingerprint(object):
- def __init__(self, *args, **kwargs):
- pass
+ def __init__(self, fingerprint = None):
+ self.fingerprint = fingerprint
def __repr__(self):
return '<Fingerprint %s>' % self.fingerprint
################################################################################
class Uid(object):
- def __init__(self, *args, **kwargs):
- pass
+ def __init__(self, uid = None, name = None):
+ self.uid = uid
+ self.name = name
def __eq__(self, val):
if isinstance(val, str):
'binary_acl',
'binary_acl_map',
'build_queue',
- 'build_queue_files',
'changelogs_text',
'component',
'config',
'files',
'fingerprint',
'keyrings',
- 'changes',
'keyring_acl_map',
'location',
'maintainer',
'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 = (
'suite_src_formats',
'suite_build_queue_copy',
'udeb_contents',
+ # see the comment above
+ 'changes',
+ 'build_queue_files',
)
views = (
'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), \