Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ language: php
sudo: enabled
dist: trusty
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- nightly
Expand Down
18 changes: 14 additions & 4 deletions src/DB/Data/LocalTableData.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,22 @@ public function getChangeDiff($table, $key) {

$wrapCast = function($arr, $p) {
return array_map(function($el) use ($p) {
return "CAST(`{$p}`.`{$el}` AS CHAR CHARACTER SET utf8)";
return "CAST(IFNULL(`{$p}`.`{$el}`,'') AS CHAR CHARACTER SET utf8)";
}, $arr);
};

$wrapNullCheck = function($arr, $p) {
return array_map(function($el) use ($p) {
return "IF(`{$p}`.`{$el}` IS NULL,'NULL','-')";
}, $arr);
};

$columnsAas = implode(',', $wrapAs($columns1, 'a', 's_'));
$columnsA = implode(',', $wrapCast($columns1, 'a'));
$columnsA0 = implode(',', $wrapNullCheck($columns1, 'a'));
$columnsBas = implode(',', $wrapAs($columns2, 'b', 't_'));
$columnsB = implode(',', $wrapCast($columns2, 'b'));
$columnsB0 = implode(',', $wrapNullCheck($columns2, 'b'));

$keyCols = implode(' AND ', array_map(function($el) {
return "a.{$el} = b.{$el}";
Expand All @@ -123,10 +131,12 @@ public function getChangeDiff($table, $key) {
$result = $this->source->select(
"SELECT * FROM (
SELECT $columnsAas, $columnsBas, MD5(concat($columnsA)) AS hash1,
MD5(concat($columnsB)) AS hash2 FROM {$db1}.{$table} as a
INNER JOIN {$db2}.{$table} as b
MD5(concat($columnsB)) AS hash2,
CONCAT($columnsA0) AS nullvalues1, CONCAT($columnsB0) AS nullvalues2
FROM {$db1}.{$table} as a
INNER JOIN {$db2}.{$table} as b
ON $keyCols
) t WHERE hash1 <> hash2");
) t WHERE hash1 <> hash2 || nullvalues1 <> nullvalues2");
$this->source->setFetchMode(\PDO::FETCH_ASSOC);

foreach ($result as $row) {
Expand Down