Skip to content
Snippets Groups Projects
Commit 1d2bef0a authored by Thomas Müller's avatar Thomas Müller
Browse files

Use a special filter expression for Oracle to filter the prefix - fixes #13220

parent ddf81c2e
Branches
No related tags found
No related merge requests found
...@@ -228,8 +228,9 @@ class ConvertType extends Command { ...@@ -228,8 +228,9 @@ class ConvertType extends Command {
} }
protected function getTables(Connection $db) { protected function getTables(Connection $db) {
$filterExpression = '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
$db->getConfiguration()-> $db->getConfiguration()->
setFilterSchemaAssetsExpression('/^'.$this->config->getSystemValue('dbtableprefix', 'oc_').'/'); setFilterSchemaAssetsExpression($filterExpression);
return $db->getSchemaManager()->listTableNames(); return $db->getSchemaManager()->listTableNames();
} }
......
...@@ -34,6 +34,13 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection { ...@@ -34,6 +34,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. * Initializes a new instance of the Connection class.
* *
......
...@@ -22,8 +22,13 @@ class OC_DB_MDB2SchemaWriter { ...@@ -22,8 +22,13 @@ class OC_DB_MDB2SchemaWriter {
$xml->addChild('overwrite', 'false'); $xml->addChild('overwrite', 'false');
$xml->addChild('charset', 'utf8'); $xml->addChild('charset', 'utf8');
$conn->getConfiguration()-> // FIX ME: bloody work around
setFilterSchemaAssetsExpression('/^' . $config->getSystemValue('dbtableprefix', 'oc_') . '/'); 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) { foreach ($conn->getSchemaManager()->listTables() as $table) {
self::saveTable($table, $xml->addChild('table')); self::saveTable($table, $xml->addChild('table'));
......
...@@ -75,9 +75,9 @@ class Migrator { ...@@ -75,9 +75,9 @@ class Migrator {
* @var \Doctrine\DBAL\Schema\Table[] $tables * @var \Doctrine\DBAL\Schema\Table[] $tables
*/ */
$tables = $targetSchema->getTables(); $tables = $targetSchema->getTables();
$filterExpression = $this->getFilterExpression();
$this->connection->getConfiguration()-> $this->connection->getConfiguration()->
setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/'); setFilterSchemaAssetsExpression($filterExpression);
$existingTables = $this->connection->getSchemaManager()->listTableNames(); $existingTables = $this->connection->getSchemaManager()->listTableNames();
foreach ($tables as $table) { foreach ($tables as $table) {
...@@ -161,8 +161,9 @@ class Migrator { ...@@ -161,8 +161,9 @@ class Migrator {
} }
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
$connection->getConfiguration()-> $filterExpression = $this->getFilterExpression();
setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/'); $this->connection->getConfiguration()->
setFilterSchemaAssetsExpression($filterExpression);
$sourceSchema = $connection->getSchemaManager()->createSchema(); $sourceSchema = $connection->getSchemaManager()->createSchema();
// remove tables we don't know about // remove tables we don't know about
...@@ -230,4 +231,8 @@ class Migrator { ...@@ -230,4 +231,8 @@ class Migrator {
$script .= PHP_EOL; $script .= PHP_EOL;
return $script; return $script;
} }
protected function getFilterExpression() {
return '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
}
} }
...@@ -51,4 +51,9 @@ class OracleMigrator extends NoCheckMigrator { ...@@ -51,4 +51,9 @@ class OracleMigrator extends NoCheckMigrator {
$script .= PHP_EOL; $script .= PHP_EOL;
return $script; return $script;
} }
protected function getFilterExpression() {
return '/^"' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
}
} }
...@@ -32,9 +32,9 @@ class PgSqlTools { ...@@ -32,9 +32,9 @@ class PgSqlTools {
* @return null * @return null
*/ */
public function resynchronizeDatabaseSequences(Connection $conn) { public function resynchronizeDatabaseSequences(Connection $conn) {
$filterExpression = '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
$databaseName = $conn->getDatabase(); $databaseName = $conn->getDatabase();
$conn->getConfiguration()-> $conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/');
foreach ($conn->getSchemaManager()->listSequences() as $sequence) { foreach ($conn->getSchemaManager()->listSequences() as $sequence) {
$sequenceName = $sequence->getName(); $sequenceName = $sequence->getName();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment