Opened 19 years ago
Closed 19 years ago
#2013 closed defect (fixed)
management.py: initial SQL data doesn't recognize empty strings properly
Reported by: | 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.
Note:
See TracTickets
for help on using tickets.
Fixed in [3003].