Opened 9 years ago

Closed 9 years ago

#2013 closed defect (fixed)

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

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

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 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [3003].

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