summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES17
-rw-r--r--lib/sqlalchemy/databases/mysql.py6
-rw-r--r--test/dialect/mysql.py25
3 files changed, 37 insertions, 11 deletions
diff --git a/CHANGES b/CHANGES
index 9596524d5..9fa7ad598 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,8 +4,8 @@ CHANGES
0.4.0beta6
----------
-- mapper compilation has been reorganized such that most compilation
- occurs upon mapper construction. this allows us to have fewer
+- Mapper compilation has been reorganized such that most compilation
+ occurs upon mapper construction. This allows us to have fewer
calls to mapper.compile() and also to allow class-based properties
to force a compilation (i.e. User.addresses == 7 will compile all
mappers; this is [ticket:758]). The only caveat here is that
@@ -13,13 +13,14 @@ CHANGES
so mappers within inheritance relationships need to be constructed in
inheritance order (which should be the normal case anyway).
-- removed "parameters" argument from clauseelement.compile(), replaced with
- "column_keys". the parameters sent to execute() only interact with the
- insert/update statement compilation process in terms of the column names
- present but not the values for those columns.
- produces more consistent execute/executemany behavior, simplifies things a
- bit internally.
+- Removed "parameters" argument from clauseelement.compile(), replaced with
+ "column_keys". The parameters sent to execute() only interact with the
+ insert/update statement compilation process in terms of the column names
+ present but not the values for those columns. Produces more consistent
+ execute/executemany behavior, simplifies things a bit internally.
+- Fixed reflection of the empty string for mysql enums.
+
0.4.0beta5
----------
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py
index 6d5c54578..507876481 100644
--- a/lib/sqlalchemy/databases/mysql.py
+++ b/lib/sqlalchemy/databases/mysql.py
@@ -1106,7 +1106,7 @@ class MSEnum(MSString):
self.enums = strip_enums
self.strict = kw.pop('strict', False)
- length = max([len(v) for v in strip_enums])
+ length = max([len(v) for v in strip_enums] + [0])
super(MSEnum, self).__init__(length, **kw)
def bind_processor(self, dialect):
@@ -2175,7 +2175,7 @@ class MySQLSchemaReflector(object):
r'(?:\((\d+)\))?(?=\,|$))+' % quotes)
# 'foo' or 'foo','bar' or 'fo,o','ba''a''r'
- self._re_csv_str = _re_compile(r'\x27(?:\x27\x27|[^\x27])+\x27')
+ self._re_csv_str = _re_compile(r'\x27(?:\x27\x27|[^\x27])*\x27')
# 123 or 123,456
self._re_csv_int = _re_compile(r'\d+')
@@ -2192,7 +2192,7 @@ class MySQLSchemaReflector(object):
r'%(iq)s(?P<name>(?:%(esc_fq)s|[^%(fq)s])+)%(fq)s +'
r'(?P<coltype>\w+)'
r'(?:\((?P<arg>(?:\d+|\d+,\d+|'
- r'(?:\x27(?:\x27\x27|[^\x27])+\x27,?)+))\))?'
+ r'(?:\x27(?:\x27\x27|[^\x27])*\x27,?)+))\))?'
r'(?: +(?P<unsigned>UNSIGNED))?'
r'(?: +(?P<zerofill>ZEROFILL))?'
r'(?: +CHARACTER SET +(?P<charset>\w+))?'
diff --git a/test/dialect/mysql.py b/test/dialect/mysql.py
index 1cf6b437c..8a5bac6e6 100644
--- a/test/dialect/mysql.py
+++ b/test/dialect/mysql.py
@@ -558,6 +558,30 @@ class TypesTest(AssertMixin):
enum_table.drop()
@testing.supported('mysql')
+ def test_enum_parse(self):
+ """More exercises for the ENUM type."""
+
+ db = testbase.db
+ enum_table = Table('mysql_enum', MetaData(testbase.db),
+ Column('e1', mysql.MSEnum("'a'")),
+ Column('e2', mysql.MSEnum("''")),
+ Column('e3', mysql.MSEnum("'a'", "''")),
+ Column('e4', mysql.MSEnum("''", "'a'")),
+ 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"]
+ finally:
+ enum_table.drop()
+
+ @testing.supported('mysql')
@testing.exclude('mysql', '<', (5, 0, 0))
def test_type_reflection(self):
# (ask_for, roundtripped_as_if_different)
@@ -583,6 +607,7 @@ class TypesTest(AssertMixin):
( mysql.MSBlob(1234), mysql.MSBlob()),
( mysql.MSMediumBlob(),),
( mysql.MSLongBlob(),),
+ ( mysql.MSEnum("''","'fleem'"), ),
]
columns = [Column('c%i' % (i + 1), t[0]) for i, t in enumerate(specs)]