diff --git a/README.md b/README.md index 14136b4..daed738 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ cd zongji git checkout fix-143 ``` -Apply SQL commands from *zongji.sql* into DB. +Apply *zongji.sql* script into DB. Copy *config.json* to *config.local.json* and place your local configuration there. diff --git a/config.json b/config.json index 7237058..832a8a1 100644 --- a/config.json +++ b/config.json @@ -3,7 +3,8 @@ "host": "localhost", "port": 3306, "user": "zongji", - "password": "password" + "password": "password", + "database": "util" }, "includeEvents": [ "tablemap", diff --git a/index.js b/index.js index aa0165b..d30a77e 100644 --- a/index.js +++ b/index.js @@ -65,7 +65,7 @@ async function main() { }; const [res] = await db.query( - 'SELECT `logName`, `position` FROM `util`.`binlogQueue` WHERE code = ?', + 'SELECT `logName`, `position` FROM `binlogQueue` WHERE code = ?', [config.queue] ); if (res.length) { @@ -98,7 +98,7 @@ async function flushQueue() { for (const fk of fks) ids.push([fk]); await db.query(config.addQuery, [ids]); await db.query( - 'REPLACE INTO `util`.`binlogQueue` (`code`, `logName`, `position`) VALUES (?, ?, ?)', + 'REPLACE INTO `binlogQueue` (`code`, `logName`, `position`) VALUES (?, ?, ?)', [config.queue, filename, nextPosition] ); fks.clear(); @@ -108,10 +108,12 @@ function equals(a, b) { if (a === b) return true; const type = typeof a; - if (type !== typeof b) + if (a == null || b == null || type !== typeof b) return false; - if (type == 'object' && a instanceof Date) - return a.getTime() === b.getTime(); + if (type === 'object' && a.constructor === b.constructor) { + if (a instanceof Date) + return a.getTime() === b.getTime(); + } return false; }