added tsv csv parsers on select query

# not completed parsers work on stream
This commit is contained in:
Pavel
2019-09-18 17:55:17 +04:00
committed by Pavel
parent f6ea85faf0
commit f42b32907f
2 changed files with 76 additions and 54 deletions

View File

@@ -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"
})
];