Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rowCount not working as intended? #36

Closed
jbergknoff opened this issue Jan 8, 2016 · 1 comment
Closed

rowCount not working as intended? #36

jbergknoff opened this issue Jan 8, 2016 · 1 comment

Comments

@jbergknoff
Copy link
Contributor

The CopyStreamQuery class exposes a property rowCount which does not appear to work correctly. Here's a slightly modified example from the readme:

var fs = require('fs');
var pg = require('pg');
var copyFrom = require('pg-copy-streams').from;

pg.connect("postgres://...", function(err, client, done) {
  client.query("CREATE TABLE IF NOT EXISTS my_table (col1 INT, col2 INT, col3 INT)");
  copyQuery = copyFrom('COPY my_table FROM STDIN');
  var stream = client.query(copyQuery);
  var fileStream = fs.createReadStream('some_file.tsv')
  fileStream.pipe(stream).on('finish', function() { console.log('rowCount: %d', copyQuery.rowCount); process.exit(); });
});

I prepared some_file.tsv with 4 rows. The output is rowCount: 1. The data passing through CopyStreamQuery._transform is

<Buffer 31 09 32 09 33 0a 34 09 35 09 36 0a 37 09 38 09 39 0a 31 30 09 31 31 09 31 32 0a>
i.e. the contents of the entire some_file.tsv:
1   2   3
4   5   6
7   8   9
10  11  12

I can split my inbound stream on line breaks, but, unless I do, the rowCount feature seems to not be working as intended.

@jbergknoff
Copy link
Contributor Author

Closed by #37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant