]> err.no Git - dak/commitdiff
Fix the DebVersion type in dbconn.py.
authorTorsten Werner <twerner@debian.org>
Thu, 13 Jan 2011 18:57:46 +0000 (19:57 +0100)
committerTorsten Werner <twerner@debian.org>
Thu, 13 Jan 2011 18:58:21 +0000 (19:58 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py
tests/create_pickle_file.py
tests/db_test.py

index c2d51786cc31d9f072ddbe304f7cb14b870fc998..bae2bb355c3cc24869d0c166f027adba4955de43 100755 (executable)
@@ -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']
 
 ################################################################################
 
index 74c50a0edd745da9ac360d8796b56b7cdbaa344a..63d139674d4d1571f63c826fdaa02f10f20726f2 100755 (executable)
@@ -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
index d8c976af3a8692b3d4312e9d72b94fef4c2a90d9..cdae54a03e5e378a15df5afa98105e62a6bb8ac6 100644 (file)
@@ -42,7 +42,6 @@ class DBDakTestCase(DakTestCase):
         self.session = DBConn().session()
 
     def tearDown(self):
-        #pass
         self.session.close()
         #self.metadata.drop_all()