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``::
return process
else:
return None
-
class MSDecimal(MSNumeric):
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
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
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
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
Column('e2', mysql.MSEnum("''")),
Column('e3', mysql.MSEnum("'a'", "''")),
Column('e4', mysql.MSEnum("''", "'a'")),
- Column('e5', mysql.MSEnum("''", "'''a'''", "'b''b'")))
+ Column('e5', mysql.MSEnum("''", "'''a'''", "'b''b'", "''''")))
try:
enum_table.create()
reflected = Table('mysql_enum', MetaData(testbase.db),
autoload=True)
for t in enum_table, reflected:
- assert t.c.e1.type.enums == ['a']
- assert t.c.e2.type.enums == ['']
- assert t.c.e3.type.enums == ['a', '']
- assert t.c.e4.type.enums == ['', 'a']
- assert t.c.e5.type.enums == ['', "''a''", "b''b"]
+ assert t.c.e1.type.enums == ["a"]
+ assert t.c.e2.type.enums == [""]
+ assert t.c.e3.type.enums == ["a", ""]
+ assert t.c.e4.type.enums == ["", "a"]
+ assert t.c.e5.type.enums == ["", "'a'", "b'b", "'"]
finally:
enum_table.drop()