From bfe7a692261760517199a3797191fd214fc2ee6c Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 14 Jun 2018 13:43:09 +0200 Subject: Fixed migrations with dash into db name --- .../CoreBundle/Doctrine/WallabagMigration.php | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php b/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php new file mode 100644 index 00000000..eb5ae407 --- /dev/null +++ b/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php @@ -0,0 +1,43 @@ +container = $container; + } + + protected function getTable($tableName) + { + $table = $this->container->getParameter('database_table_prefix') . $tableName; + + // escape table name is handled using " on postgresql + if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) { + return '"' . $table . '"'; + } + + // return escaped table + return '`' . $table . '`'; + } +} -- cgit v1.2.3 From 49b4c875985c7b001af711079662dd3684373229 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 14 Jun 2018 14:15:07 +0200 Subject: We should able to get the table name unescaped When we want to perform complex queries to retrieve metadata from the database --- src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php b/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php index eb5ae407..7aa2409a 100644 --- a/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php +++ b/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php @@ -9,6 +9,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; abstract class WallabagMigration extends AbstractMigration implements ContainerAwareInterface { + const UN_ESCAPED_TABLE = true; + /** * @var ContainerInterface */ @@ -28,10 +30,14 @@ abstract class WallabagMigration extends AbstractMigration implements ContainerA $this->container = $container; } - protected function getTable($tableName) + protected function getTable($tableName, $unEscaped = false) { $table = $this->container->getParameter('database_table_prefix') . $tableName; + if (self::UN_ESCAPED_TABLE === $unEscaped) { + return $table; + } + // escape table name is handled using " on postgresql if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) { return '"' . $table . '"'; -- cgit v1.2.3