vierge-noire / cakephp-test-suite-light

A fast test suite for CakePHP applications
MIT License
13 stars 7 forks source link

Handle tables names with (-) while creating triggers #67

Open HtSpChakradharCholleti opened 8 months ago

HtSpChakradharCholleti commented 8 months ago

Issue Description:

The createTrigger statement stops execution when there is a hyphen (-) in the table name. This causes the code to fail when attempting to execute CREATE TRIGGER statements for tables with hyphenated names.

Proposed Solution:

To resolve this issue, we can modify the code to enclose the table name in backticks (`) in the CREATE TRIGGER statement. This will ensure that table names containing hyphens are properly handled.

Affected Code:


public function createTriggers(): void {
    $stmts = "";
    foreach ($this->getAllTablesExceptPhinxlogsAndCollector(true) as $table) {
        $stmts .= "CREATE TRIGGER {$this->getTriggerName($table)} AFTER INSERT ON `{$table}`";
        // Add trigger definition...
    }
}
pabloelcolombiano commented 2 months ago

Yes, good idea! Feel free to send us your PR.