diff --git a/src/Storage/IntColumnHandler.php b/src/Storage/IntColumnHandler.php index 7d8912d..931ab32 100644 --- a/src/Storage/IntColumnHandler.php +++ b/src/Storage/IntColumnHandler.php @@ -106,7 +106,7 @@ abstract class IntColumnHandler implements IntColumnHandlerInterface { if (strlen($trigger) > 64) { $trigger = substr($trigger, 0, 56) . substr(hash('sha256', $trigger), 0, 8); } - $this->dropTrigger($trigger); + $this->connection->query("DROP TRIGGER IF EXISTS $trigger"); if ($body) { $this->createTrigger($trigger, $op, $prefixed_name, $body); } @@ -156,14 +156,4 @@ abstract class IntColumnHandler implements IntColumnHandlerInterface { } - /** - * Actually drops the trigger. - * - * @param string $trigger - * The name of the trigger. - */ - protected function dropTrigger($trigger) { - $this->connection->query("DROP TRIGGER IF EXISTS $trigger"); - } - } diff --git a/src/Storage/IntColumnHandlerSQLite.php b/src/Storage/IntColumnHandlerSQLite.php index f584950..5d047c8 100644 --- a/src/Storage/IntColumnHandlerSQLite.php +++ b/src/Storage/IntColumnHandlerSQLite.php @@ -18,8 +18,11 @@ class IntColumnHandlerSQLite extends IntColumnHandler { * {@inheritdoc} */ protected function createTrigger($trigger, $op, $prefixed_name, $body) { - $trigger = $this->removeQuoteIdentifiers($trigger); - $table_name = $this->removeQuoteIdentifiers($prefixed_name); + $parts = explode('.', $prefixed_name); + // Simpletest for example prefixes with a database name but SQLite does + // not support referencing databases in the body of the trigger (even if it + // is the same database the triggering table is in). + $table_name = array_pop($parts); $query = " CREATE TRIGGER $trigger AFTER $op ON $prefixed_name FOR EACH ROW @@ -34,29 +37,4 @@ class IntColumnHandlerSQLite extends IntColumnHandler { $this->connection->query("$query; END", [], ['allow_delimiter_in_query' => TRUE]); } - /** - * {@inheritdoc} - */ - protected function dropTrigger($trigger) { - $trigger = $this->removeQuoteIdentifiers($trigger); - $this->connection->query("DROP TRIGGER IF EXISTS $trigger"); - } - - /** - * Helper method to remove quote identifiers. - * - * @param string $value - * The input string. - * - * @return string - * The return value. - */ - private function removeQuoteIdentifiers($value) { - $parts = explode('.', $value); - // Simpletest for example prefixes with a database name but SQLite does - // not support referencing databases in the body of the trigger (even if it - // is the same database the triggering table is in). - return array_pop($parts); - } - }