mirror of
https://github.com/lingble/clickhouse.git
synced 2025-11-21 21:34:51 +00:00
added tsv csv parsers on select query
# not completed parsers work on stream
This commit is contained in:
35
test/test.js
35
test/test.js
@@ -79,30 +79,30 @@ describe('Select', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('use callback with csv format', callback => {
|
||||
clickhouse.query(`${sql} format CSV`).exec((err, rows) => {
|
||||
it('use callback #3 with csv format', callback => {
|
||||
clickhouse.query(`${sql} format CSVWithNames`).exec((err, rows) => {
|
||||
expect(err).to.not.be.ok();
|
||||
|
||||
expect(rows).to.have.length(rowCount);
|
||||
expect(rows[0]).to.eql([0, '0', '1970-01-02' ]);
|
||||
expect(rows[0]).to.eql({ number: 0, str: 0, date: '1970-01-02' });
|
||||
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('use callback #2 with csv format', callback => {
|
||||
clickhouse.query(`${sql} format CSV`, (err, rows) => {
|
||||
it('use callback #4 with csv format', callback => {
|
||||
clickhouse.query(`${sql} format CSVWithNames`, (err, rows) => {
|
||||
expect(err).to.not.be.ok();
|
||||
|
||||
expect(rows).to.have.length(rowCount);
|
||||
expect(rows[0]).to.eql([0, '0', '1970-01-02' ]);
|
||||
expect(rows[0]).to.eql({ number: 0, str: 0, date: '1970-01-02' });
|
||||
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
it('use callback with tsv format', callback => {
|
||||
it('use callback #5 with tsv format', callback => {
|
||||
clickhouse.query(`${sql} format TabSeparatedWithNames`).exec((err, rows) => {
|
||||
expect(err).to.not.be.ok();
|
||||
|
||||
@@ -114,7 +114,7 @@ describe('Select', () => {
|
||||
});
|
||||
|
||||
|
||||
it('use callback #2 with tsv format', callback => {
|
||||
it('use callback #6 with tsv format', callback => {
|
||||
clickhouse.query(`${sql} format TabSeparatedWithNames`, (err, rows) => {
|
||||
expect(err).to.not.be.ok();
|
||||
|
||||
@@ -134,6 +134,7 @@ describe('Select', () => {
|
||||
|
||||
clickhouse.query(sql).stream()
|
||||
.on('data', () => ++i)
|
||||
// TODO: on this case you should catch error
|
||||
.on('error', err => error = err)
|
||||
.on('end', () => {
|
||||
expect(error).to.not.be.ok();
|
||||
@@ -525,6 +526,24 @@ describe('Constructor options', () => {
|
||||
new ClickHouse({
|
||||
host: 'http://localhost:8124',
|
||||
port: 8123
|
||||
}),
|
||||
|
||||
new ClickHouse({
|
||||
host: 'http://localhost:8124',
|
||||
port: 8123,
|
||||
format: "json"
|
||||
}),
|
||||
|
||||
new ClickHouse({
|
||||
host: 'http://localhost:8124',
|
||||
port: 8123,
|
||||
format: "tsv"
|
||||
}),
|
||||
|
||||
new ClickHouse({
|
||||
host: 'http://localhost:8124',
|
||||
port: 8123,
|
||||
format: "csv"
|
||||
})
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user