Get mysql_sql_mode parameter from config
Patch Ia527e850671ab9542db5864617384cee21e91bf6 added mysql_sql_mode option to config, so we should get it's value from CONF object, not from function argument. Closes-Bug: #1288445 Change-Id: I4be81718399393d817185abe36f4cc4d3da15000
This commit is contained in:
parent
2961172aa9
commit
56fc0f91c3
|
@ -762,16 +762,13 @@ class EngineFacade(object):
|
|||
"""
|
||||
|
||||
def __init__(self, sql_connection,
|
||||
sqlite_fk=False, mysql_sql_mode=None,
|
||||
autocommit=True, expire_on_commit=False, **kwargs):
|
||||
sqlite_fk=False, autocommit=True,
|
||||
expire_on_commit=False, **kwargs):
|
||||
"""Initialize engine and sessionmaker instances.
|
||||
|
||||
:param sqlite_fk: enable foreign keys in SQLite
|
||||
:type sqlite_fk: bool
|
||||
|
||||
:param mysql_sql_mode: set SQL mode in MySQL
|
||||
:type mysql_sql_mode: string
|
||||
|
||||
:param autocommit: use autocommit mode for created Session instances
|
||||
:type autocommit: bool
|
||||
|
||||
|
@ -780,6 +777,8 @@ class EngineFacade(object):
|
|||
|
||||
Keyword arguments:
|
||||
|
||||
:keyword mysql_sql_mode: the SQL mode to be used for MySQL sessions.
|
||||
(defaults to TRADITIONAL)
|
||||
:keyword idle_timeout: timeout before idle sql connections are reaped
|
||||
(defaults to 3600)
|
||||
:keyword connection_debug: verbosity of SQL debugging information.
|
||||
|
@ -807,7 +806,7 @@ class EngineFacade(object):
|
|||
self._engine = create_engine(
|
||||
sql_connection=sql_connection,
|
||||
sqlite_fk=sqlite_fk,
|
||||
mysql_sql_mode=mysql_sql_mode,
|
||||
mysql_sql_mode=kwargs.get('mysql_sql_mode', 'TRADITIONAL'),
|
||||
idle_timeout=kwargs.get('idle_timeout', 3600),
|
||||
connection_debug=kwargs.get('connection_debug', 0),
|
||||
max_pool_size=kwargs.get('max_pool_size'),
|
||||
|
@ -849,8 +848,7 @@ class EngineFacade(object):
|
|||
|
||||
@classmethod
|
||||
def from_config(cls, connection_string, conf,
|
||||
sqlite_fk=False, mysql_sql_mode=None,
|
||||
autocommit=True, expire_on_commit=False):
|
||||
sqlite_fk=False, autocommit=True, expire_on_commit=False):
|
||||
"""Initialize EngineFacade using oslo.config config instance options.
|
||||
|
||||
:param connection_string: SQLAlchemy connection string
|
||||
|
@ -862,9 +860,6 @@ class EngineFacade(object):
|
|||
:param sqlite_fk: enable foreign keys in SQLite
|
||||
:type sqlite_fk: bool
|
||||
|
||||
:param mysql_sql_mode: set SQL mode in MySQL
|
||||
:type mysql_sql_mode: string
|
||||
|
||||
:param autocommit: use autocommit mode for created Session instances
|
||||
:type autocommit: bool
|
||||
|
||||
|
@ -875,7 +870,6 @@ class EngineFacade(object):
|
|||
|
||||
return cls(sql_connection=connection_string,
|
||||
sqlite_fk=sqlite_fk,
|
||||
mysql_sql_mode=mysql_sql_mode,
|
||||
autocommit=autocommit,
|
||||
expire_on_commit=expire_on_commit,
|
||||
**dict(conf.database.items()))
|
||||
|
|
|
@ -351,13 +351,13 @@ class EngineFacadeTestCase(test.BaseTestCase):
|
|||
conf = mock.MagicMock()
|
||||
conf.database.items.return_value = [
|
||||
('connection_debug', 100),
|
||||
('max_pool_size', 10)
|
||||
('max_pool_size', 10),
|
||||
('mysql_sql_mode', 'TRADITIONAL'),
|
||||
]
|
||||
|
||||
session.EngineFacade.from_config('sqlite:///:memory:', conf,
|
||||
autocommit=False,
|
||||
expire_on_commit=True,
|
||||
mysql_sql_mode='TRADITIONAL')
|
||||
expire_on_commit=True)
|
||||
|
||||
conf.database.items.assert_called_once_with()
|
||||
create_engine.assert_called_once_with(
|
||||
|
|
Loading…
Reference in New Issue