diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-11-28 00:44:16 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-11-28 00:44:16 +0000 |
commit | d56e11ffe290515e44d8bdeda76f06ff87a2b096 (patch) | |
tree | b290e2ec80656d30b7c9d1610093ffe391527773 /lib/sqlalchemy | |
parent | 3f6e94e8185591bd5a32f3558bb5419e0df01763 (diff) | |
download | sqlalchemy-d56e11ffe290515e44d8bdeda76f06ff87a2b096.tar.gz |
default value of assert_unicode is None on String, False on create_engine(), and True on Unicode type.
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/engine/default.py | 2 | ||||
-rw-r--r-- | lib/sqlalchemy/types.py | 10 |
3 files changed, 7 insertions, 9 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index 03b9a749c..742164412 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -725,7 +725,7 @@ class MSText(_StringType, sqltypes.TEXT): _StringType.__init__(self, **kwargs) sqltypes.TEXT.__init__(self, length, - kwargs.get('convert_unicode', False)) + kwargs.get('convert_unicode', False), kwargs.get('assert_unicode', None)) def get_col_spec(self): if self.length: @@ -889,7 +889,7 @@ class MSString(_StringType, sqltypes.String): _StringType.__init__(self, **kwargs) sqltypes.String.__init__(self, length, - kwargs.get('convert_unicode', False)) + kwargs.get('convert_unicode', False), kwargs.get('assert_unicode', None)) def get_col_spec(self): if self.length: diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index fab5d05b0..0e50093ee 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -35,7 +35,7 @@ class DefaultDialect(base.Dialect): supports_pk_autoincrement = True dbapi_type_map = {} - def __init__(self, convert_unicode=False, assert_unicode=None, encoding='utf-8', default_paramstyle='named', paramstyle=None, dbapi=None, **kwargs): + def __init__(self, convert_unicode=False, assert_unicode=False, encoding='utf-8', default_paramstyle='named', paramstyle=None, dbapi=None, **kwargs): self.convert_unicode = convert_unicode self.assert_unicode = assert_unicode self.encoding = encoding diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 93e7d6066..e23a695f3 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -307,16 +307,14 @@ class String(Concatenable, TypeEngine): self.assert_unicode = assert_unicode def adapt(self, impltype): - return impltype(length=self.length, convert_unicode=self.convert_unicode) + return impltype(length=self.length, convert_unicode=self.convert_unicode, assert_unicode=self.assert_unicode) def bind_processor(self, dialect): if self.convert_unicode or dialect.convert_unicode: - if self.assert_unicode is not None: - assert_unicode = self.assert_unicode - elif dialect.assert_unicode is not None: - assert_unicode = dialect.assert_unicode + if self.assert_unicode is None: + assert_unicode = bool(dialect.assert_unicode) else: - assert_unicode = True + assert_unicode = self.assert_unicode def process(value): if isinstance(value, unicode): return value.encode(dialect.encoding) |