Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/spotty-buckets-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/mysql-zongji': patch
---

Add test verifying datetime fraction format.
2 changes: 1 addition & 1 deletion test/settings/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
password: 'my_password',
charset: 'utf8mb4_unicode_ci',
port: process.env.TEST_MYSQL_PORT,
dateStrings: process.env.TEST_DATE_STRINGS === 'true',
dateStrings: true,
database: 'zongji_test',
timeZone: 'Z'
// debug: true
Expand Down
51 changes: 29 additions & 22 deletions test/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,24 @@ function defineTypeTest(name, fields, testRows, customTest) {
}
};

expectEvents(
test,
eventLog,
[
expectedWrite
],
testRows.length,
() => {
test.equal(errorLog.length, 0);
expectEvents(test, eventLog, [expectedWrite], testRows.length, () => {
test.equal(errorLog.length, 0);

const binlogRows = eventLog.reduce((prev, curr) => {
if (curr.getTypeName() === 'WriteRows') {
prev = prev.concat(curr.rows);
}
return prev;
}, []);

if (customTest) {
customTest.bind(selectResult)(test, { rows: binlogRows });
} else {
assert.deepEqual(selectResult, binlogRows);
const binlogRows = eventLog.reduce((prev, curr) => {
if (curr.getTypeName() === 'WriteRows') {
prev = prev.concat(curr.rows);
}
return prev;
}, []);

test.end();
if (customTest) {
customTest.bind(selectResult)(test, { rows: binlogRows });
} else {
assert.deepEqual(selectResult, binlogRows);
}
);

test.end();
});
});
});
});
Expand Down Expand Up @@ -258,6 +250,21 @@ defineTypeTest(
]
);

defineTypeTest(
'time_fraction',
['TIME(3) NULL', 'DATETIME(6) NULL', 'TIMESTAMP(2) NULL'],
[["'17:51:04.777'", "'2018-09-08 17:51:04.777'", "'2018-09-08 17:51:04.777'"]],
function (_, event) {
assert.deepEqual(event.rows, [
{
col0: '17:51:04.777',
col1: '2018-09-08 17:51:04.777000',
col2: '2018-09-08 17:51:04.78'
}
]);
}
);

defineTypeTest(
'datetime_no_fraction',
['DATETIME NULL'],
Expand Down