aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-01-13 10:31:04 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-01-13 10:31:04 +0100
commitdc86cbd1e275f01840b304751a02ecbe4043c51e (patch)
treee209ec2a077be264fc654fa0d595007eed3469db
parent67168e12e6d786e916ffdbf72cda5e69be0a680e (diff)
parent1d2bef0a0116eefdd81221ba7502497845f0747b (diff)
downloadnextcloud-server-dc86cbd1e275f01840b304751a02ecbe4043c51e.tar.gz
nextcloud-server-dc86cbd1e275f01840b304751a02ecbe4043c51e.zip
Merge pull request #13271 from owncloud/fix-table-prefix-oracle-master
Use a special filter expression for Oracle to filter the prefix - fixes ...
-rw-r--r--core/command/db/converttype.php3
-rw-r--r--lib/private/db/connection.php7
-rw-r--r--lib/private/db/mdb2schemawriter.php9
-rw-r--r--lib/private/db/migrator.php13
-rw-r--r--lib/private/db/oraclemigrator.php5
-rw-r--r--lib/private/db/pgsqltools.php4
6 files changed, 32 insertions, 9 deletions
diff --git a/core/command/db/converttype.php b/core/command/db/converttype.php
index 8d1560b0511..9d03b705d12 100644
--- a/core/command/db/converttype.php
+++ b/core/command/db/converttype.php
@@ -228,8 +228,9 @@ class ConvertType extends Command {
}
protected function getTables(Connection $db) {
+ $filterExpression = '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
$db->getConfiguration()->
- setFilterSchemaAssetsExpression('/^'.$this->config->getSystemValue('dbtableprefix', 'oc_').'/');
+ setFilterSchemaAssetsExpression($filterExpression);
return $db->getSchemaManager()->listTableNames();
}
diff --git a/lib/private/db/connection.php b/lib/private/db/connection.php
index f2fcd8730af..53935c1e1ed 100644
--- a/lib/private/db/connection.php
+++ b/lib/private/db/connection.php
@@ -35,6 +35,13 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection {
}
/**
+ * @return string
+ */
+ public function getPrefix() {
+ return $this->tablePrefix;
+ }
+
+ /**
* Initializes a new instance of the Connection class.
*
* @param array $params The connection parameters.
diff --git a/lib/private/db/mdb2schemawriter.php b/lib/private/db/mdb2schemawriter.php
index a42cd86ba54..1fb71ab398b 100644
--- a/lib/private/db/mdb2schemawriter.php
+++ b/lib/private/db/mdb2schemawriter.php
@@ -22,8 +22,13 @@ class OC_DB_MDB2SchemaWriter {
$xml->addChild('overwrite', 'false');
$xml->addChild('charset', 'utf8');
- $conn->getConfiguration()->
- setFilterSchemaAssetsExpression('/^' . $config->getSystemValue('dbtableprefix', 'oc_') . '/');
+ // FIX ME: bloody work around
+ if ($config->getSystemValue('dbtype', 'sqlite') === 'oci') {
+ $filterExpression = '/^"' . preg_quote($conn->getPrefix()) . '/';
+ } else {
+ $filterExpression = '/^' . preg_quote($conn->getPrefix()) . '/';
+ }
+ $conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
foreach ($conn->getSchemaManager()->listTables() as $table) {
self::saveTable($table, $xml->addChild('table'));
diff --git a/lib/private/db/migrator.php b/lib/private/db/migrator.php
index 8ccc02e36a5..fcf5aae0258 100644
--- a/lib/private/db/migrator.php
+++ b/lib/private/db/migrator.php
@@ -75,9 +75,9 @@ class Migrator {
* @var \Doctrine\DBAL\Schema\Table[] $tables
*/
$tables = $targetSchema->getTables();
-
+ $filterExpression = $this->getFilterExpression();
$this->connection->getConfiguration()->
- setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/');
+ setFilterSchemaAssetsExpression($filterExpression);
$existingTables = $this->connection->getSchemaManager()->listTableNames();
foreach ($tables as $table) {
@@ -161,8 +161,9 @@ class Migrator {
}
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
- $connection->getConfiguration()->
- setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/');
+ $filterExpression = $this->getFilterExpression();
+ $this->connection->getConfiguration()->
+ setFilterSchemaAssetsExpression($filterExpression);
$sourceSchema = $connection->getSchemaManager()->createSchema();
// remove tables we don't know about
@@ -230,4 +231,8 @@ class Migrator {
$script .= PHP_EOL;
return $script;
}
+
+ protected function getFilterExpression() {
+ return '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
+ }
}
diff --git a/lib/private/db/oraclemigrator.php b/lib/private/db/oraclemigrator.php
index b80295cbd60..9ae35023838 100644
--- a/lib/private/db/oraclemigrator.php
+++ b/lib/private/db/oraclemigrator.php
@@ -51,4 +51,9 @@ class OracleMigrator extends NoCheckMigrator {
$script .= PHP_EOL;
return $script;
}
+
+ protected function getFilterExpression() {
+ return '/^"' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
+ }
+
}
diff --git a/lib/private/db/pgsqltools.php b/lib/private/db/pgsqltools.php
index f3204d4c7b6..9336917cc5c 100644
--- a/lib/private/db/pgsqltools.php
+++ b/lib/private/db/pgsqltools.php
@@ -32,9 +32,9 @@ class PgSqlTools {
* @return null
*/
public function resynchronizeDatabaseSequences(Connection $conn) {
+ $filterExpression = '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
$databaseName = $conn->getDatabase();
- $conn->getConfiguration()->
- setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/');
+ $conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
foreach ($conn->getSchemaManager()->listSequences() as $sequence) {
$sequenceName = $sequence->getName();