﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2013	management.py: initial SQL data doesn't recognize empty strings properly	curtis.thompson@…	Adrian Holovaty	"The regular expressions for get_sql_initial_data_for_model() don't detect empty strings properly.  

For e.g. 

{{{
INSERT INTO myapp_person (first_name, last_name) VALUES ('', 'Lennon');
}}}
would cause the following when manage.py sqlreset myapp is run:
{{{
INSERT INTO myapp_person (first_name, last_name) VALUES (
', 'Lennon');
}}}

Here's the patch to fix the problem:

{{{
Index: management.py
===================================================================
--- management.py	(revision 2995)
+++ management.py	(working copy)
@@ -334,8 +334,8 @@

         r""""""(           # each statement is...
         (?:             # one or more chunks of ...
             (?:[^;'""]+) # not the end of a statement or start of a quote
-          | (?:'[^']+') # something in single quotes
-          | (?:""[^""]+"") # something in double quotes
+          | (?:'[^']*') # something in single quotes
+          | (?:""[^""]*"") # something in double quotes
         )+)"""""", re.VERBOSE)
 
     # Find custom SQL, if it's available.        
}}}"	defect	closed	Core (Other)	dev	major	fixed			Unreviewed	0	0	0	0	0	0
