#18977: bad removal of comments in custom_sql_for_model
-------------------------------+--------------------
     Reporter:  trott@…        |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  Uncategorized  |    Version:  1.4
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 When providing initial data for models as SQL files, the function
 "custom_sql_for_model" in django/core/management/sql.py
 will cut away comments (good)  ... and also valid string data (not good).

 Example:
 {{{
 INSERT INTO myapp_mymodel (somecolumn) VALUES ('Joung--at--Heart');
 }}}

 will result in:
 {{{
 INSERT INTO myapp_mymodel (somecolumn) VALUES ('Joung;
 at;
 Heart');
 }}}

 to be executed by the database .. which in turn complains about
 unterminated strings.

 The source of this dilemma is in line 173 of sql.py:
 {{{
                 statement = re.sub(ur"--.*([\n\Z]|$)", "", statement)

 }}}

 Possible solution; force the regex to the linestart (using the caret):
 {{{
                 statement = re.sub(ur"^--.*([\n\Z]|$)", "", statement)
 }}}
 That should catch almost all comments (and the others should not bother
 us...)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18977>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to