summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-07-27 14:30:29 +0200
committerJoas Schilling <coding@schilljs.com>2018-07-27 14:45:22 +0200
commit008c8dde1aac6b0351f8145e20a4c8a93bf77372 (patch)
tree22c2017cfcd7950e7c65a5f18c2edbe71af9e779
parent5e0bfe5c16b1b53d64efcbcc38b22f84d8664959 (diff)
downloadnextcloud-server-008c8dde1aac6b0351f8145e20a4c8a93bf77372.tar.gz
nextcloud-server-008c8dde1aac6b0351f8145e20a4c8a93bf77372.zip
Ignore custom prefixes which are longer
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/private/DB/MigrationService.php18
-rw-r--r--tests/lib/DB/MigrationsTest.php20
2 files changed, 19 insertions, 19 deletions
diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php
index 2079a33e176..94b2b55e16f 100644
--- a/lib/private/DB/MigrationService.php
+++ b/lib/private/DB/MigrationService.php
@@ -457,7 +457,7 @@ class MigrationService {
if ($toSchema instanceof SchemaWrapper) {
$targetSchema = $toSchema->getWrappedSchema();
- $this->ensureOracleIdentifierLengthLimit($targetSchema);
+ $this->ensureOracleIdentifierLengthLimit($targetSchema, strlen($this->connection->getPrefix()));
$this->connection->migrateToSchema($targetSchema);
$toSchema->performDropTableCalls();
}
@@ -471,28 +471,28 @@ class MigrationService {
$this->markAsExecuted($version);
}
- public function ensureOracleIdentifierLengthLimit(Schema $schema) {
+ public function ensureOracleIdentifierLengthLimit(Schema $schema, int $prefixLength) {
$sequences = $schema->getSequences();
foreach ($schema->getTables() as $table) {
- if (\strlen($table->getName()) > 30) {
+ if (\strlen($table->getName()) - $prefixLength > 27) {
throw new \InvalidArgumentException('Table name "' . $table->getName() . '" is too long.');
}
foreach ($table->getColumns() as $thing) {
- if (\strlen($thing->getName()) > 30) {
+ if (\strlen($thing->getName()) - $prefixLength > 27) {
throw new \InvalidArgumentException('Column name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.');
}
}
foreach ($table->getIndexes() as $thing) {
- if (\strlen($thing->getName()) > 30) {
+ if (\strlen($thing->getName()) - $prefixLength > 27) {
throw new \InvalidArgumentException('Index name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.');
}
}
foreach ($table->getForeignKeys() as $thing) {
- if (\strlen($thing->getName()) > 30) {
+ if (\strlen($thing->getName()) - $prefixLength > 27) {
throw new \InvalidArgumentException('Foreign key name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.');
}
}
@@ -516,17 +516,17 @@ class MigrationService {
$isUsingDefaultName = strtolower($defaultName) === $indexName;
}
- if (!$isUsingDefaultName && \strlen($indexName) > 30) {
+ if (!$isUsingDefaultName && \strlen($indexName) - $prefixLength > 27) {
throw new \InvalidArgumentException('Primary index name on "' . $table->getName() . '" is too long.');
}
- if ($isUsingDefaultName && \strlen($table->getName()) > 26) {
+ if ($isUsingDefaultName && \strlen($table->getName()) - $prefixLength > 23) {
throw new \InvalidArgumentException('Primary index name on "' . $table->getName() . '" is too long.');
}
}
}
foreach ($sequences as $sequence) {
- if (\strlen($sequence->getName()) > 30) {
+ if (\strlen($sequence->getName()) - $prefixLength > 27) {
throw new \InvalidArgumentException('Sequence name "' . $sequence->getName() . '" is too long.');
}
}
diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php
index 95656e3feda..dd06b9096cc 100644
--- a/tests/lib/DB/MigrationsTest.php
+++ b/tests/lib/DB/MigrationsTest.php
@@ -268,7 +268,7 @@ class MigrationsTest extends \Test\TestCase {
->method('getSequences')
->willReturn([$sequence]);
- self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema]);
+ self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]);
}
public function testEnsureOracleIdentifierLengthLimitValidWithPrimaryKey() {
@@ -303,7 +303,7 @@ class MigrationsTest extends \Test\TestCase {
->method('getSequences')
->willReturn([]);
- self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema]);
+ self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]);
}
public function testEnsureOracleIdentifierLengthLimitValidWithPrimaryKeyDefault() {
@@ -348,7 +348,7 @@ class MigrationsTest extends \Test\TestCase {
->method('getSequences')
->willReturn([]);
- self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema]);
+ self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]);
}
/**
@@ -365,7 +365,7 @@ class MigrationsTest extends \Test\TestCase {
->method('getTables')
->willReturn([$table]);
- self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema]);
+ self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]);
}
/**
@@ -410,7 +410,7 @@ class MigrationsTest extends \Test\TestCase {
->method('getTables')
->willReturn([$table]);
- self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema]);
+ self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]);
}
/**
@@ -445,7 +445,7 @@ class MigrationsTest extends \Test\TestCase {
->method('getTables')
->willReturn([$table]);
- self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema]);
+ self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]);
}
/**
@@ -471,7 +471,7 @@ class MigrationsTest extends \Test\TestCase {
->method('getTables')
->willReturn([$table]);
- self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema]);
+ self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]);
}
/**
@@ -500,7 +500,7 @@ class MigrationsTest extends \Test\TestCase {
->method('getTables')
->willReturn([$table]);
- self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema]);
+ self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]);
}
/**
@@ -532,7 +532,7 @@ class MigrationsTest extends \Test\TestCase {
->method('getTables')
->willReturn([$table]);
- self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema]);
+ self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]);
}
/**
@@ -552,6 +552,6 @@ class MigrationsTest extends \Test\TestCase {
->method('getSequences')
->willReturn([$sequence]);
- self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema]);
+ self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]);
}
}