summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2017-05-12 11:07:15 +0100
committerAlex Pott2017-05-12 11:07:15 +0100
commit3441b94eba1570d199bd47a6a1238d556363998f (patch)
tree5940509e4cad61f4047465fa5810efe114f3dcbe
parent240524f08c22a03d3cc0c7d9a63bd88e898c9f1f (diff)
Issue #2742953 by Jo Fitzgerald, mikeryan, Adita: SqlBase::mapJoinable() should not join across databases with PostgreSQL
-rw-r--r--core/modules/migrate/src/Plugin/migrate/source/SqlBase.php8
-rw-r--r--core/modules/migrate/tests/src/Unit/SqlBaseTest.php9
2 files changed, 13 insertions, 4 deletions
diff --git a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
index a8c66b2..de1accd 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
@@ -357,6 +357,14 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
return FALSE;
}
+ // FALSE if driver is PostgreSQL and database doesn't match.
+ if ($id_map_database_options['driver'] === 'pgsql' &&
+ $source_database_options['driver'] === 'pgsql' &&
+ $id_map_database_options['database'] != $source_database_options['database']
+ ) {
+ return FALSE;
+ }
+
foreach (['username', 'password', 'host', 'port', 'namespace', 'driver'] as $key) {
if (isset($source_database_options[$key])) {
if ($id_map_database_options[$key] != $source_database_options[$key]) {
diff --git a/core/modules/migrate/tests/src/Unit/SqlBaseTest.php b/core/modules/migrate/tests/src/Unit/SqlBaseTest.php
index b7dc5ed..b8097a3 100644
--- a/core/modules/migrate/tests/src/Unit/SqlBaseTest.php
+++ b/core/modules/migrate/tests/src/Unit/SqlBaseTest.php
@@ -111,13 +111,14 @@ class SqlBaseTest extends UnitTestCase {
['driver' => 'mysql', 'username' => 'different_from_map', 'password' => 'different_from_map'],
['driver' => 'mysql', 'username' => 'different_from_source', 'password' => 'different_from_source'],
],
- // Returns true because source and id map connection options are the same.
+ // Returns false because driver is pgsql and the databases are not the
+ // same.
[
+ FALSE,
TRUE,
TRUE,
- TRUE,
- ['driver' => 'pgsql', 'username' => 'same_value', 'password' => 'same_value'],
- ['driver' => 'pgsql', 'username' => 'same_value', 'password' => 'same_value'],
+ ['driver' => 'pgsql', 'database' => '1.pgsql', 'username' => 'same_value', 'password' => 'same_value'],
+ ['driver' => 'pgsql', 'database' => '2.pgsql', 'username' => 'same_value', 'password' => 'same_value'],
],
// Returns false because driver is sqlite and the databases are not the
// same.