﻿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
18977	bad removal of comments in custom_sql_for_model	trott@…	nobody	"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...)


"	Bug	closed	Uncategorized	1.4	Normal	duplicate			Unreviewed	0	0	0	0	0	0
