# HG changeset patch # User adustman # Date 1238287934 0 # Node ID 7a60c4574bafc761cb757eb5e33bb9bad2b7059e # Parent 2d6a35051f64658168f5afedec58f701272417aa figleaf revealed that the INSERT_VALUES regex never matched. Added a test for this, and fixed the regex (forgot to add group anchors) diff -r 2d6a35051f64 -r 7a60c4574baf MySQLdb/cursors.py --- a/MySQLdb/cursors.py Sat Mar 28 13:37:58 2009 +0000 +++ b/MySQLdb/cursors.py Sun Mar 29 00:52:14 2009 +0000 @@ -14,11 +14,9 @@ import sys import weakref -INSERT_VALUES = re.compile(r"\svalues\s*" - r"(\(((?.+values\s*)" + r"(?P\(((?.*)", re.I) class Cursor(object): diff -r 2d6a35051f64 -r 7a60c4574baf tests/test_MySQLdb_capabilities.py --- a/tests/test_MySQLdb_capabilities.py Sat Mar 28 13:37:58 2009 +0000 +++ b/tests/test_MySQLdb_capabilities.py Sun Mar 29 00:52:14 2009 +0000 @@ -81,6 +81,18 @@ except self.connection.ProgrammingError, msg: self.failUnless(msg[0] == ER.NO_SUCH_TABLE) + def test_INSERT_VALUES(self): + from MySQLdb.cursors import INSERT_VALUES + query = """INSERT FOO (a, b, c) VALUES (%s, %s, %s)""" + matched = INSERT_VALUES.match(query) + self.failUnless(matched) + start = matched.group('start') + end = matched.group('end') + values = matched.group('values') + self.failUnless(start == """INSERT FOO (a, b, c) VALUES """) + self.failUnless(values == "(%s, %s, %s)") + self.failUnless(end == "") + def test_ping(self): self.connection.ping()