]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
utilize the zxjdbc PostgresqlHandler for better Decimal handling. hopefully
authorPhilip Jenvey <pjenvey@underboss.org>
Sat, 23 Apr 2011 20:10:53 +0000 (13:10 -0700)
committerPhilip Jenvey <pjenvey@underboss.org>
Sat, 23 Apr 2011 20:10:53 +0000 (13:10 -0700)
this won't be necessary eventually (refs http://bugs.jython.org/issue1499)

lib/sqlalchemy/dialects/postgresql/zxjdbc.py

index a9a38d234b5cb9944205994606f53802f17a015a..f64b42acbd596c2e09ceeb6826b2c2c5d6facfbb 100644 (file)
@@ -13,12 +13,29 @@ The official Postgresql JDBC driver is at http://jdbc.postgresql.org/.
 
 """
 from sqlalchemy.connectors.zxJDBC import ZxJDBCConnector
-from sqlalchemy.dialects.postgresql.base import PGDialect
+from sqlalchemy.dialects.postgresql.base import PGDialect, PGExecutionContext
+
+class PGExecutionContext_zxjdbc(PGExecutionContext):
+
+    def create_cursor(self):
+        cursor = self._dbapi_connection.cursor()
+        cursor.datahandler = self.dialect.DataHandler(cursor.datahandler)
+        return cursor
+
 
 class PGDialect_zxjdbc(ZxJDBCConnector, PGDialect):
     jdbc_db_name = 'postgresql'
     jdbc_driver_name = 'org.postgresql.Driver'
 
+    execution_ctx_cls = PGExecutionContext_zxjdbc
+
+    supports_native_decimal = True
+
+    def __init__(self, *args, **kwargs):
+        super(PGDialect_zxjdbc, self).__init__(*args, **kwargs)
+        from com.ziclix.python.sql.handler import PostgresqlDataHandler
+        self.DataHandler = PostgresqlDataHandler
+
     def _get_server_version_info(self, connection):
         return tuple(int(x) for x in connection.connection.dbversion.split('.'))