MySQL-python-1.2.2
Python 2.4.4
GNU/Linux
cursors.py:8
"insert_values" is a compiled re expression which pulls format strings out of queries. It's used on line 27 in executemany().
The regex used for insert_values was changed from:
r'\svalues\s((.+))'
to:
r"\svalues\s((((?<!\)'.?).(?<!\)?'|.)+?))"
in revision 470. This change appears to break the use of SQL using pyformat format strings.
old_iv = re.compile(r"\svalues\s((((?<!\)'.?).(?<!\)?'|.)+?))", re.IGNORECASE)
new_iv = re.compile(r"\svalues\s((((?<!\)'.?).(?<!\)?'|.)+?))", re.IGNORECASE)
old_iv = re.compile(r'\svalues\s*((.+))', re.IGNORECASE)
pySQL = '''INSERT INTO blah (col1,col2) VALUES ( %(val1)s,%(val2)s )'''
SQL = '''INSERT INTO blah (col1,col2) VALUES ( %s,%s )'''
old_iv.search(SQL).group(1)
'( %s,%s )'
old_iv.search(pySQL).group(1)
'( %(val1)s,%(val2)s )'
new_iv.search(SQL).group(1)
'( %s,%s )'
new_iv.search(pySQL).group(1)
'( %(val1)'
The last line here is the problem as errors occur when it tries to insert the values.
I haven't even tried to figure out what the new regex is doing so I'm not sure if this was an intentional change.
Logged In: YES
user_id=1750488
Originator: YES
oops, ignore that first old_iv declaration in the example code, sorry
Logged In: YES
user_id=64259
Originator: NO
This popped up in the SQLAlchemy tests, running against MySQL-python 1.2.2b3, 1.2.2c1, and 1.2.2 final.
Wedging a pass for %([^(]+) into the insert_values regex seems to do the trick.
Pretty sure this was fixed in 1.2.3 or earlier