Custom SQL can not be executed in any way
|Reported by:||vzima||Owned by:||nobody|
|Component:||Core (Management commands)||Version:||master|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
According to documentation it should be possible to use custom SQL for databases. But there is no way how we can "create SQL functions, views, triggers, etc." as documentation says.
When you try to use initial SQL it parses and messes what is in file unless it is some basic statement like INSERT. You can not really add trigger, because django messes your SQL by running what is between semicolons separately.
When you try to use post_syncdb signal to run your custom SQL then you can not use flush command, because it fails on database errors that your triggers/functions/constraints/... already exists and it is not possible to write IF NOT EXISTS everywhere.
Best solution for all is to remove the parser for custom SQL, it can not prevent errors anyway, we can still insert wrong values. Just let us upload our SQLs without messing them up and let us handle our SQL ourselves.