Opened 5 years ago

Closed 5 years ago

#22665 closed Uncategorized (invalid)

Creating trigger in custom sql for mySQL failed with 1046 error

Reported by: hudan@… 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.

Change History (1)

comment:1 Changed 5 years ago by Tim Graham

Resolution: invalid
Status: newclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top