diff --git a/plugins/sources/sql.inc b/plugins/sources/sql.inc index 2cd444d..ae42d18 100644 --- a/plugins/sources/sql.inc +++ b/plugins/sources/sql.inc @@ -357,7 +357,7 @@ class MigrateSourceSQL extends MigrateSource { $map_join .= "$field_name = map.$map_key"; } - $alias = $this->query->leftJoin($this->activeMap->getQualifiedMapTable(), + $alias = $this->query->leftJoin($this->activeMap->getQualifiedMapTable(FALSE), 'map', $map_join); $conditions->isNull($alias . '.sourceid1'); $conditions->condition($alias . '.needs_update', MigrateMap::STATUS_NEEDS_UPDATE); @@ -385,8 +385,8 @@ class MigrateSourceSQL extends MigrateSource { // optimization to the query. $add_highwater_condition = TRUE; if (!$this->mapJoinable) { - $count_needs_update = db_query('SELECT COUNT(*) FROM {' . - $this->activeMap->getQualifiedMapTable() . '} WHERE needs_update = 1') + $count_needs_update = db_query('SELECT COUNT(*) FROM ' . + $this->activeMap->getQualifiedMapTable(TRUE) . ' WHERE needs_update = 1') ->fetchField(); if ($count_needs_update > 0) { $add_highwater_condition = FALSE; diff --git a/plugins/sources/sqlmap.inc b/plugins/sources/sqlmap.inc index ccfacd4..f17a216 100644 --- a/plugins/sources/sqlmap.inc +++ b/plugins/sources/sqlmap.inc @@ -32,20 +32,28 @@ class MigrateSQLMap extends MigrateMap { * * @return string */ - public function getQualifiedMapTable() { + public function getQualifiedMapTable($add_braces = FALSE) { $options = $this->connection->getConnectionOptions(); $prefix = $this->connection->tablePrefix($this->mapTable); if ($prefix) { - return $this->mapTable; + $table_name = $this->mapTable; + if ($add_braces) { + $table_name = "{$table_name}"; + } + return $table_name; } else { $dbname = $options['database']; + $table_name = $this->mapTable; if (!empty($options['driver']) && $options['driver'] == 'mysql') { // Backtick the db name on mysql to ensure dbs with hyphens work. $dbname = "`{$dbname}`"; } - return $dbname . '.' . $this->mapTable; + if ($add_braces) { + $table_name = "{$table_name}"; + } + return $dbname . '.' . $table_name; } }