diff --git a/test/fixtures/data.csv b/test/fixtures/data.csv index 56715c993..8edc5d7e7 100644 --- a/test/fixtures/data.csv +++ b/test/fixtures/data.csv @@ -1,4 +1,4 @@ -1,Hello World -2,This is a test -3,For loading data from a file -4,中文内容 +1,Hello World,123.456,test1,test5,2016-06-07T10:56:14,2016-06-07T10:56:14 +2,This is a test,789.012,test2,test6,2016-06-07T10:56:14,2016-06-07T10:56:14 +3,For loading data from a file,345.678,test3,test7,2016-06-07T10:56:14,2016-06-07T10:56:14 +4,中文内容,901.234,test4,test8,2016-06-07T10:56:14,2016-06-07T10:56:14 diff --git a/test/integration/connection/test-load-data-infile.js b/test/integration/connection/test-load-data-infile.js index 96fe602f6..b84be64ed 100644 --- a/test/integration/connection/test-load-data-infile.js +++ b/test/integration/connection/test-load-data-infile.js @@ -15,13 +15,18 @@ common.getTestConnection(function (err, connection) { 'CREATE TEMPORARY TABLE ?? (', '`id` int(11) unsigned NOT NULL AUTO_INCREMENT,', '`title` varchar(255),', + '`num` varchar(255),', + '`test_col_1` varchar(255) DEFAULT NULL,', + '`test_col_2` varchar(255) NOT NULL,', + '`test_col_3` datetime NOT NULL,', + '`test_col_4` datetime NOT NULL,', 'PRIMARY KEY (`id`)', ') ENGINE=InnoDB DEFAULT CHARSET=utf8' ].join('\n'), [table], assert.ifError); var sql = 'LOAD DATA LOCAL INFILE ? INTO TABLE ?? CHARACTER SET utf8 ' + - 'FIELDS TERMINATED BY ? (id, title)'; + 'FIELDS TERMINATED BY ? (id, title, num, test_col_1, test_col_2, test_col_3, test_col_4)'; connection.query(sql, [path, table, ','], function (err, result) { assert.ifError(err); @@ -33,8 +38,21 @@ common.getTestConnection(function (err, connection) { assert.equal(rows.length, 4); assert.equal(rows[0].id, 1); assert.equal(rows[0].title, 'Hello World'); + assert.equal(rows[0].num, 123.456); + assert.equal(rows[0].test_col_1, 'test1'); + assert.equal(rows[0].test_col_2, 'test5'); + + var testTime = (new Date(2016, 5, 7, 10, 56, 14)).getTime(); + assert.equal(rows[0].test_col_3.getTime(), testTime); + assert.equal(rows[0].test_col_4.getTime(), testTime); + assert.equal(rows[3].id, 4); assert.equal(rows[3].title, '中文内容'); + assert.equal(rows[3].num, 901.234); + assert.equal(rows[3].test_col_1, 'test4'); + assert.equal(rows[3].test_col_2, 'test8'); + assert.equal(rows[3].test_col_3.getTime(), testTime); + assert.equal(rows[3].test_col_4.getTime(), testTime); }); connection.query(sql, [badPath, table, ','], function (err) { diff --git a/test/integration/connection/test-multiple-statements-load-data-infile.js b/test/integration/connection/test-multiple-statements-load-data-infile.js index 397c926da..1b682aab3 100644 --- a/test/integration/connection/test-multiple-statements-load-data-infile.js +++ b/test/integration/connection/test-multiple-statements-load-data-infile.js @@ -14,13 +14,18 @@ common.getTestConnection({multipleStatements: true}, function (err, connection) 'CREATE TEMPORARY TABLE ?? (', '`id` int(11) unsigned NOT NULL AUTO_INCREMENT,', '`title` varchar(255),', + '`num` varchar(255),', + '`test_col_1` varchar(255) DEFAULT NULL,', + '`test_col_2` varchar(255) NOT NULL,', + '`test_col_3` datetime NOT NULL,', + '`test_col_4` datetime NOT NULL,', 'PRIMARY KEY (`id`)', ') ENGINE=InnoDB DEFAULT CHARSET=utf8' ].join('\n'), [table], assert.ifError); var stmt = 'LOAD DATA LOCAL INFILE ? INTO TABLE ?? CHARACTER SET utf8 ' + - 'FIELDS TERMINATED BY ? (id, title)'; + 'FIELDS TERMINATED BY ? (id, title, num, test_col_1, test_col_2, test_col_3, test_col_4)'; var sql = connection.format(stmt, [path, table, ',']) + ';' + @@ -38,8 +43,21 @@ common.getTestConnection({multipleStatements: true}, function (err, connection) assert.equal(rows.length, 4); assert.equal(rows[0].id, 1); assert.equal(rows[0].title, 'Hello World'); + assert.equal(rows[0].num, 123.456); + assert.equal(rows[0].test_col_1, 'test1'); + assert.equal(rows[0].test_col_2, 'test5'); + + var testTime = (new Date(2016, 5, 7, 10, 56, 14)).getTime(); + assert.equal(rows[0].test_col_3.getTime(), testTime); + assert.equal(rows[0].test_col_4.getTime(), testTime); + assert.equal(rows[3].id, 4); assert.equal(rows[3].title, '中文内容'); + assert.equal(rows[3].num, 901.234); + assert.equal(rows[3].test_col_1, 'test4'); + assert.equal(rows[3].test_col_2, 'test8'); + assert.equal(rows[3].test_col_3.getTime(), testTime); + assert.equal(rows[3].test_col_4.getTime(), testTime); }); connection.end(assert.ifError);