From ff9c5007a87c830fb763b43b451db3e4f002c31f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 9 Jul 2008 16:33:38 +0000 Subject: [PATCH] - Unicode, UnicodeText types now set "assert_unicode" and "convert_unicode" by default, but accept overriding **kwargs for these values. --- CHANGES | 4 ++++ lib/sqlalchemy/types.py | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 68ac6ff893..8d83e79168 100644 --- a/CHANGES +++ b/CHANGES @@ -49,6 +49,10 @@ CHANGES strings to insert after CREATE in the CREATE TABLE statement. [ticket:1075] + - Unicode, UnicodeText types now set "assert_unicode" and + "convert_unicode" by default, but accept overriding + **kwargs for these values. + - sqlite - Modified SQLite's representation of "microseconds" to match the output of str(somedatetime), i.e. in that the diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index bae079e649..6b63377545 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -423,16 +423,16 @@ class Unicode(String): """A synonym for String(length, convert_unicode=True, assert_unicode='warn').""" def __init__(self, length=None, **kwargs): - kwargs['convert_unicode'] = True - kwargs['assert_unicode'] = 'warn' + kwargs.setdefault('convert_unicode', True) + kwargs.setdefault('assert_unicode', 'warn') super(Unicode, self).__init__(length=length, **kwargs) class UnicodeText(Text): """A synonym for Text(convert_unicode=True, assert_unicode='warn').""" def __init__(self, length=None, **kwargs): - kwargs['convert_unicode'] = True - kwargs['assert_unicode'] = 'warn' + kwargs.setdefault('convert_unicode', True) + kwargs.setdefault('assert_unicode', 'warn') super(UnicodeText, self).__init__(length=length, **kwargs) class Integer(TypeEngine): -- 2.47.3