[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master 1/2] Add workaround for Unicode support in database.



Signed-off-by: Torsten Werner <twerner@debian.org>
---
 config/debian/dak.conf   |    2 ++
 daklib/dbconn.py         |   19 +++++++++++--------
 tests/dbtest_contents.py |    3 +++
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/config/debian/dak.conf b/config/debian/dak.conf
index bc9da6d..97aaa01 100644
--- a/config/debian/dak.conf
+++ b/config/debian/dak.conf
@@ -458,6 +458,8 @@ DB
   PoolSize 17;
   // MaxOverflow shouldn't exceed postgresql.conf's max_connections - PoolSize
   MaxOverflow 13;
+  // should be false for encoding == SQL_ASCII
+  Unicode "false"
 };
 
 Archive
diff --git a/daklib/dbconn.py b/daklib/dbconn.py
index 1bf44c8..ef93f52 100755
--- a/daklib/dbconn.py
+++ b/daklib/dbconn.py
@@ -3306,14 +3306,17 @@ class DBConn(object):
             connstr = "postgres:///%s" % cnf["DB::Name"]
             if cnf["DB::Port"] and cnf["DB::Port"] != "-1":
                 connstr += "?port=%s" % cnf["DB::Port"]
-        if not cnf.has_key('DB::PoolSize'):
-            cnf['DB::PoolSize'] = '5'
-        if not cnf.has_key('DB::MaxOverflow'):
-            cnf['DB::MaxOverflow'] = '10'
-
-        self.db_pg   = create_engine(connstr, echo=self.debug,
-            pool_size=int(cnf['DB::PoolSize']),
-            max_overflow=int(cnf['DB::MaxOverflow']))
+
+        engine_args = { 'echo': self.debug }
+        if cnf.has_key('DB::PoolSize'):
+            engine_args['pool_size'] = int(cnf['DB::PoolSize'])
+        if cnf.has_key('DB::MaxOverflow'):
+            engine_args['max_overflow'] = int(cnf['DB::MaxOverflow'])
+        if sa_major_version >= 0.6 and cnf.has_key('DB::Unicode') and \
+            cnf['DB::Unicode'] == 'false':
+            engine_args['use_native_unicode'] = False
+
+        self.db_pg   = create_engine(connstr, **engine_args)
         self.db_meta = MetaData()
         self.db_meta.bind = self.db_pg
         self.db_smaker = sessionmaker(bind=self.db_pg,
diff --git a/tests/dbtest_contents.py b/tests/dbtest_contents.py
index 7402601..1cfe46b 100755
--- a/tests/dbtest_contents.py
+++ b/tests/dbtest_contents.py
@@ -154,6 +154,9 @@ class ContentsTestCase(DBDakTestCase):
             self.otype['udeb'], self.comp['main'])
         self.assertEqual('tests/fixtures/ftp/squeeze/main/Contents-i386.gz', \
             cw.output_filename())
+        # test unicode support
+        self.binary['hello_2.2-1_i386'].contents.append(BinContents(file = '\xc3\xb6'))
+        self.session.commit()
 
     def test_scan_contents(self):
         self.setup_binaries()
-- 
1.7.2.3



Reply to: