diff options
-rw-r--r-- | oslo_db/sqlalchemy/enginefacade.py | 4 | ||||
-rw-r--r-- | oslo_db/sqlalchemy/engines.py | 10 | ||||
-rw-r--r-- | oslo_db/tests/sqlalchemy/test_sqlalchemy.py | 2 |
3 files changed, 13 insertions, 3 deletions
diff --git a/oslo_db/sqlalchemy/enginefacade.py b/oslo_db/sqlalchemy/enginefacade.py index f337cff..2c88726 100644 --- a/oslo_db/sqlalchemy/enginefacade.py +++ b/oslo_db/sqlalchemy/enginefacade.py @@ -142,7 +142,9 @@ class _TransactionFactory(object): 'connection_trace': _Default(False), 'max_retries': _Default(10), 'retry_interval': _Default(10), - 'thread_checkin': _Default(True) + 'thread_checkin': _Default(True), + 'json_serializer': _Default(None), + 'json_deserializer': _Default(None), } self._maker_cfg = { 'expire_on_commit': _Default(False), diff --git a/oslo_db/sqlalchemy/engines.py b/oslo_db/sqlalchemy/engines.py index 17610cb..54852b4 100644 --- a/oslo_db/sqlalchemy/engines.py +++ b/oslo_db/sqlalchemy/engines.py @@ -106,7 +106,9 @@ def create_engine(sql_connection, sqlite_fk=False, mysql_sql_mode=None, connection_debug=0, max_pool_size=None, max_overflow=None, pool_timeout=None, sqlite_synchronous=True, connection_trace=False, max_retries=10, retry_interval=10, - thread_checkin=True, logging_name=None): + thread_checkin=True, logging_name=None, + json_serializer=None, + json_deserializer=None): """Return a new SQLAlchemy engine.""" url = sqlalchemy.engine.url.make_url(sql_connection) @@ -124,7 +126,9 @@ def create_engine(sql_connection, sqlite_fk=False, mysql_sql_mode=None, url, engine_args, max_pool_size=max_pool_size, max_overflow=max_overflow, - pool_timeout=pool_timeout + pool_timeout=pool_timeout, + json_serializer=json_serializer, + json_deserializer=json_deserializer, ) engine = sqlalchemy.create_engine(url, **engine_args) @@ -186,6 +190,8 @@ def _init_connection_args(url, engine_args, **kw): # it's supported for PostgreSQL 8.*. More details at: # http://docs.sqlalchemy.org/en/rel_0_9/dialects/postgresql.html engine_args['client_encoding'] = 'utf8' + engine_args['json_serializer'] = kw.get('json_serializer') + engine_args['json_deserializer'] = kw.get('json_deserializer') @_init_connection_args.dispatch_for("mysql") diff --git a/oslo_db/tests/sqlalchemy/test_sqlalchemy.py b/oslo_db/tests/sqlalchemy/test_sqlalchemy.py index 49f43a1..ceb2afe 100644 --- a/oslo_db/tests/sqlalchemy/test_sqlalchemy.py +++ b/oslo_db/tests/sqlalchemy/test_sqlalchemy.py @@ -348,6 +348,8 @@ class EngineFacadeTestCase(oslo_test.BaseTestCase): sqlite_synchronous=mock.ANY, pool_timeout=mock.ANY, thread_checkin=mock.ANY, + json_serializer=None, + json_deserializer=None, ) get_maker.assert_called_once_with(engine=create_engine(), autocommit=False, |