Opened 18 years ago

Closed 18 years ago

#2013 closed defect (fixed)

management.py: initial SQL data doesn't recognize empty strings properly

Reported by: curtis.thompson@… Owned by: Adrian Holovaty
Component: Core (Other) Version: dev
Severity: major Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.        

Change History (1)

comment:1 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: newclosed

Fixed in [3003].

Note: See TracTickets for help on using tickets.
Back to Top