Bug #56493 Sychronisation: dectecting diffs on equal triggers because of refomating
Submitted: 2 Sep 2010 10:44 Modified: 14 Sep 2010 5:10
Reporter: Michael Berg Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.2.27 OS:Windows (7)
Assigned to: CPU Architecture:Any
Tags: trigger Synchronize Model spaces well fomated

[2 Sep 2010 10:44] Michael Berg
Description:
I'm creating some triggers for Tables. If I'm sychronizing with live db there are allways differences between model and db, although the sql of the triggers are equal on db and model. But he is reformating the sql at creating the trigger on the live db. 

ON MODEL:
CREATE TRIGGER `famberg_maindb`.`acc_campaigns_after_update` AFTER UPDATE ON `famberg_maindb`.`acc_campaigns`
FOR EACH ROW
BEGIN
    INSERT INTO sys_changes SET sys_changes.table = 'acc_campaigns', sys_changes.user = CURRENT_USER(), sys_changes.time = NOW(), operation = "update", primary_key = NEW.campaign_id;
END$$

CREATING ON DB:
CREATE <---- removing spaces and replacing with line breaks
DEFINER=`root`@`%` <---- adding DEFINER Keyword.
TRIGGER `famberg_maindb`.`acc_campaigns_after_update`
AFTER UPDATE ON `famberg_maindb`.`acc_campaigns`
FOR EACH ROW
BEGIN
    INSERT INTO sys_changes SET sys_changes.table = 'acc_campaigns', sys_changes.user = CURRENT_USER(), sys_changes.time = NOW(), operation = "update", primary_key = NEW.campaign_id;
END$$

It's enough if you put a space after a line of the sql code of the trigger for detecting differences. 

Because of this reformating he sychronize triggers everytime I sychronizing the Model with Database.

How to repeat:
Create a Trigger on Table with follow SQL:

-- Trigger DDL Statements
DELIMITER $$

USE `famberg_maindb`$$

CREATE(insert a space before line break or don't use line break, only space)
DEFINER=`root`@`%`
TRIGGER `database`.`triggername`
AFTER UPDATE ON `databaseb`.`table`
FOR EACH ROW
BEGIN
    statement;
END$$

Now Sychronize Model with Live DB. He will synchronzie allways you start.

Suggested fix:
You should reformat the Trigger SQL at saving in Model or reformat before compare for sychroniziation. Or just use a more common compare.
[7 Sep 2010 13:02] Johannes Taxacher
the comparison seems to catch a difference whenever theres a break in a line like:
TRIGGER
`testdb`.`testtrigger`
instead of 
TRIGGER `testdb`.`testtrigger`

or 
AFTER UPDATE ON
`testdb`.`testtable`
instead of
AFTER UPDATE ON `testdb`.`testtable`
[14 Sep 2010 5:10] Alfredo Kojima
This is the same issue as per bug #52004, although for a different object.