cursor has no method read
blissdev opened this issue · 11 comments
Hi,
I'm getting an error when trying to use the Cursor. I'm sure I'm doing something obviously wrong, but I'm at a loss. Mind taking a look?
https://gist.github.com/blissdev/25784b641d6ca41d4f7e
Thanks!
I'm guessing you're probably using an old-ish version of node-postgres. I
had to change some internals to enable hooking into the low level binary
protocol to enable pg-cursor, pg-query-stream, and pg-copy-streams so
they're only compatible with recent versions of node-postgres. Try
upgrading.
On Tue, Dec 17, 2013 at 1:49 AM, Jordan Arentsen
notifications@github.comwrote:
Hi,
I'm getting an error when trying to use the Cursor. I'm sure I'm doing
something obviously wrong, but I'm at a loss. Mind taking a look?https://gist.github.com/blissdev/25784b641d6ca41d4f7e
Thanks!
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/2
.
I've upgraded to 2.8.4 which I think is the newest and I get the same error. I have a feeling I'm doing something else wrong.
You on the most recent version of pg-cursor too? Can you PM me on
freenode? my handle is brianc
On Dec 17, 2013 2:14 PM, "Jordan Arentsen" notifications@github.com wrote:
I've upgraded to 2.8.4 which I think is the newest and I get the same
error. I have a feeling I'm doing something else wrong.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-30786496
.
Closing because we resolved this
Brianc, this issue seems to be still there.
I am using pg-cursor on linux with node version 0.10.29
pg version: 1.3.0
pg-cursor version: 0.2.0 (latest from npm install)
Code:
pg.connect(connectionString, function(err, client, done) {
if(!pgcursor)
pgcursor = client.query(new Cursor(qry));
pgcursor.read(count, function(err, rows) { });
});
This is the error message:
TypeError: Object [object Object] has no method 'read'
at /root/ash/serverside/controllers/admin/cursormodel.js:47:13
at /root/ash/serverside/node_modules/pg/lib/pool.js:55:9
at moveAlongNothingToSeeHere (/root/ash/serverside/node_modules/newrelic/lib/instrumentation/generic-pool.js:22:34)
at /root/ash/serverside/node_modules/pg/node_modules/generic-pool/lib/generic-pool.js:278:11
at /root/ash/serverside/node_modules/pg/lib/pool.js:36:18
at null. (/root/ash/serverside/node_modules/pg/lib/client.js:134:7)
at g (events.js:180:16)
at emit (events.js:117:20)
at Socket. (/root/ash/serverside/node_modules/pg/lib/connection.js:100:12)
at Socket.emit (events.js:95:17)
Can you provide code I can use to reproduce?
There isnt much code. I am trying to run the sample code on github to test.
btw, I am on 9.2 version of postgres
code:
var pgc = require('pg-cursor');
var pg = require('pg');
pg.connect(""pg://"+username_password+"@localhost/ghdata", function(err, client, done) {
if(!pgcursor)
pgcursor = client.query(new pgc(querystring));
pgcursor.read(count, function(err, rows) {
if(err) {
done(err);
cb(err, null);
return;
}
if(!rows.length) { done(); cb(null, [], rows.length); return;}
cb(null, rows, rows.length);
});
});
Ah I see - your version of node-postgres is far too old. You need the 3.x
branch for cursors to work.
Ah, shouldnt a fresh npm install fetch the latest node-postgres? (npm install pg)
Anyways, it worked when I moved to 3.4.2 version. thanks.
👍 glad to help!