- added "views=True" option to metadata.reflect(),
will add the list of available views to those
being reflected. [ticket:1936]
+
+ - engine_from_config() now accepts 'debug' for
+ 'echo', 'echo_pool', 'force' for 'convert_unicode',
+ boolean values for 'use_native_unicode'.
+ [ticket:1899]
- informix
- *Major* cleanup / modernization of the Informix
for key in configuration
if key.startswith(prefix))
for option, type_ in (
- ('convert_unicode', bool),
+ ('convert_unicode', util.bool_or_str('force')),
('pool_timeout', int),
- ('echo', bool),
- ('echo_pool', bool),
+ ('echo', util.bool_or_str('debug')),
+ ('echo_pool', util.bool_or_str('debug')),
('pool_recycle', int),
('pool_size', int),
('max_overflow', int),
('pool_threadlocal', bool),
+ ('use_native_unicode', bool),
):
util.coerce_kw_type(options, option, type_)
return options
in all cases.
"""
-
return self.cursor.lastrowid
def handle_dbapi_exception(self, e):
raise ValueError("String is not true/false: %r" % obj)
return bool(obj)
+def bool_or_str(*text):
+ """Return a callable that will evaulate a string as
+ boolean, or one of a set of "alternate" string values.
+
+ """
+ def bool_or_value(obj):
+ if obj in text:
+ return obj
+ else:
+ return asbool(obj)
+ return bool_or_value
+
def coerce_kw_type(kw, key, type_, flexi_bool=True):
"""If 'key' is present in dict 'kw', coerce its value to type 'type\_' if
necessary. If 'flexi_bool' is True, the string '0' is considered false
import StringIO
import sqlalchemy.engine.url as url
from sqlalchemy import create_engine, engine_from_config
+from sqlalchemy.engine import _coerce_config
import sqlalchemy as tsa
from sqlalchemy.test import TestBase
'z=somevalue')
assert e.echo is True
+ for param, values in [
+ ('convert_unicode', ('true', 'false', 'force')),
+ ('echo', ('true', 'false', 'debug')),
+ ('echo_pool', ('true', 'false', 'debug')),
+ ('use_native_unicode', ('true', 'false')),
+ ]:
+ for value in values:
+ config = {
+ 'sqlalchemy.url': 'postgresql://scott:tiger@somehost/test',
+ 'sqlalchemy.%s' % param : value
+ }
+ cfg = _coerce_config(config, 'sqlalchemy.')
+ assert cfg[param] == {'true':True, 'false':False}.get(value, value)
+
+
def test_custom(self):
dbapi = MockDBAPI(foober=12, lala=18, hoho={'this': 'dict'},
fooz='somevalue')