﻿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
4374	manage.py custom sql fails with triggers and sqlite	hambaloney@…	Jacob	"Ran into an issue where using the manage.py interface to bring in custom SQL containing triggers for sqlite causes it to fail with the error:

{{{

The full error: near "";"": syntax error

}}}

Dug around to find in django/core/management.py -> get_custom_sql_for_model, the sql commands are parsed by semicolons. 

sqlite triggers follow the format:

{{{
CREATE TRIGGER trigger-name [ BEFORE | AFTER ]
database-event ON [database-name .] table-name
BEGIN
trigger step;
trigger step;
END;
}}}

manage.py attempts to parse and run each line ending in a semicolon separately causing the error.

As a temporary fix I've modified management.py as follows, please don't hurt me, I know its ugly. Note, I'm using sqlite3."		closed	Uncategorized	0.96		duplicate	manage.py custom sql trigger sqlite3	hambaloney@…	Unreviewed	0	0	0	0	0	0
