From: Torsten Werner Date: Thu, 13 Jan 2011 18:57:46 +0000 (+0100) Subject: Fix the DebVersion type in dbconn.py. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cfab8b9dee9e75e4243e2239471eeaf7215dc1ee;p=dak Fix the DebVersion type in dbconn.py. Signed-off-by: Torsten Werner --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index c2d51786..bae2bb35 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -64,14 +64,23 @@ 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 + + def result_processor(self, dialect): + 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 +90,7 @@ else: ################################################################################ -__all__ = ['IntegrityError', 'SQLAlchemyError'] +__all__ = ['IntegrityError', 'SQLAlchemyError', 'DebVersion'] ################################################################################ diff --git a/tests/create_pickle_file.py b/tests/create_pickle_file.py index 74c50a0e..63d13967 100755 --- a/tests/create_pickle_file.py +++ b/tests/create_pickle_file.py @@ -3,14 +3,19 @@ # recreate the pickle file db-metadata-*.pkl that needs to be updated # after a database upgrade -from daklib.dbconn import DBConn - from sqlalchemy import create_engine, __version__ import pickle +import sys from os.path import abspath, dirname DAK_TEST_DIR = dirname(abspath(__file__)) +DAK_ROOT_DIR = dirname(DAK_TEST_DIR) +if DAK_ROOT_DIR not in sys.path: + sys.path.insert(0, DAK_ROOT_DIR) + +from daklib.dbconn import DBConn + pickle_filename = '%s/fixtures/db-metadata-%s.pkl' % (DAK_TEST_DIR, __version__) pickle_file = open(pickle_filename, 'w') metadata = DBConn().db_meta diff --git a/tests/db_test.py b/tests/db_test.py index d8c976af..cdae54a0 100644 --- a/tests/db_test.py +++ b/tests/db_test.py @@ -42,7 +42,6 @@ class DBDakTestCase(DakTestCase): self.session = DBConn().session() def tearDown(self): - #pass self.session.close() #self.metadata.drop_all()