Commit 3441b94e authored by alexpott's avatar alexpott

Issue #2742953 by Jo Fitzgerald, mikeryan, Adita: SqlBase::mapJoinable()...

Issue #2742953 by Jo Fitzgerald, mikeryan, Adita: SqlBase::mapJoinable() should not join across databases with PostgreSQL
parent 240524f0
...@@ -357,6 +357,14 @@ protected function mapJoinable() { ...@@ -357,6 +357,14 @@ protected function mapJoinable() {
return FALSE; 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) { foreach (['username', 'password', 'host', 'port', 'namespace', 'driver'] as $key) {
if (isset($source_database_options[$key])) { if (isset($source_database_options[$key])) {
if ($id_map_database_options[$key] != $source_database_options[$key]) { if ($id_map_database_options[$key] != $source_database_options[$key]) {
......
...@@ -111,13 +111,14 @@ public function sqlBaseTestProvider() { ...@@ -111,13 +111,14 @@ public function sqlBaseTestProvider() {
['driver' => 'mysql', 'username' => 'different_from_map', 'password' => 'different_from_map'], ['driver' => 'mysql', 'username' => 'different_from_map', 'password' => 'different_from_map'],
['driver' => 'mysql', 'username' => 'different_from_source', 'password' => 'different_from_source'], ['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, TRUE,
TRUE, ['driver' => 'pgsql', 'database' => '1.pgsql', 'username' => 'same_value', 'password' => 'same_value'],
['driver' => 'pgsql', 'username' => 'same_value', 'password' => 'same_value'], ['driver' => 'pgsql', 'database' => '2.pgsql', 'username' => 'same_value', 'password' => 'same_value'],
['driver' => 'pgsql', 'username' => 'same_value', 'password' => 'same_value'],
], ],
// Returns false because driver is sqlite and the databases are not the // Returns false because driver is sqlite and the databases are not the
// same. // same.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment