diff options
author | Jason Kirtland <jek@discorporate.us> | 2007-09-06 18:46:53 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2007-09-06 18:46:53 +0000 |
commit | a072e50c9d28eac08882ecb5bf274f423f0a4508 (patch) | |
tree | 8244329d78c2a71aab8d9f9ce2c43d62cf1f80bc /lib/sqlalchemy/databases/mysql.py | |
parent | 4245d758850bf847d87fe2c9b48d3df82e578c2c (diff) | |
download | sqlalchemy-a072e50c9d28eac08882ecb5bf274f423f0a4508.tar.gz |
mysql SETs and ENUMs now unescape embedded quotes before storage in .enums and .values. An ancient bug.
Diffstat (limited to 'lib/sqlalchemy/databases/mysql.py')
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index 507876481..8bbe8b683 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -81,7 +81,7 @@ multi-column key for some storage engines:: Column('gid', Integer, primary_key=True, autoincrement=False), Column('id', Integer, primary_key=True)) -MySQL SQL modes are supported. Modes that enable ``ANSI_QUOTE`` (such as +MySQL SQL modes are supported. Modes that enable ``ANSI_QUOTES`` (such as ``ANSI``) require an engine option to modify SQLAlchemy's quoting style. When using an ANSI-quoting mode, supply ``use_ansiquotes=True`` when creating your ``Engine``:: @@ -310,7 +310,6 @@ class MSNumeric(sqltypes.Numeric, _NumericType): return process else: return None - class MSDecimal(MSNumeric): @@ -1064,7 +1063,10 @@ class MSEnum(MSString): enums The range of valid values for this ENUM. Values will be used - exactly as they appear when generating schemas + exactly as they appear when generating schemas. Strings must + be quoted, as in the example above. Single-quotes are suggested + for ANSI compatability and are required for portability to servers + with ANSI_QUOTES enabled. strict Defaults to False: ensure that a given value is in this ENUM's @@ -1101,7 +1103,8 @@ class MSEnum(MSString): strip_enums = [] for a in enums: if a[0:1] == '"' or a[0:1] == "'": - a = a[1:-1] + # strip enclosing quotes and unquote interior + a = a[1:-1].replace(a[0] * 2, a[0]) strip_enums.append(a) self.enums = strip_enums @@ -1139,7 +1142,10 @@ class MSSet(MSString): values The range of valid values for this SET. Values will be used - exactly as they appear when generating schemas. + exactly as they appear when generating schemas. Strings must + be quoted, as in the example above. Single-quotes are suggested + for ANSI compatability and are required for portability to servers + with ANSI_QUOTES enabled. charset Optional, a column-level character set for this string @@ -1169,7 +1175,8 @@ class MSSet(MSString): strip_values = [] for a in values: if a[0:1] == '"' or a[0:1] == "'": - a = a[1:-1] + # strip enclosing quotes and unquote interior + a = a[1:-1].replace(a[0] * 2, a[0]) strip_values.append(a) self.values = strip_values |