Opened 10 years ago
Closed 10 years ago
#22665 closed Uncategorized (invalid)
Creating trigger in custom sql for mySQL failed with 1046 error
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.6 |
Severity: | Normal | 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
In file "clothing.mysql.sql" is trigger creation:
CREATE TRIGGER ins_laundryflow_clothing BEFORE INSERT ON laundryflow_clothing FOR EACH ROW BEGIN SET NEW.SumWash = NEW.StartWash; END
If I run "syncdb", it ends with error:
Failed to install custom SQL for laundryflow.Clothing model: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1")
If I remove "BEGIN" and "END", everything works:
CREATE TRIGGER ins_laundryflow_clothing BEFORE INSERT ON laundryflow_clothing FOR EACH ROW SET NEW.SumWash = NEW.StartWash;
Using "DELIMITER" didn't work at all. On Internet I found, that it's relevant only in command line MySQL client and shouldn't by use in Python-MySQL.
BTW> Creating stored procedures has the same problem.
Note:
See TracTickets
for help on using tickets.
It's not clear to me that this is a bug in Django. Also, initial SQL is deprecated now that we have migrations in 1.7+ so even if there is a bug, we probably wouldn't fix it at this point.