error when Update/Insert postgres #4

Closed
datcatloi opened this Issue Apr 1, 2014 · 8 comments

Comments

Projects
None yet
3 participants
var sql = " UPDATE sessions SET date_end = now() where uuid = $1 ";
    this.getEngine().query(sql,[uuid],function(err,res){
        if(err){
            logger.error("Error when updateDateEndSession "+ err);
            callbackError(err);
            return;
        }
        if(res.rows.affectedRows === 0){
            //failed because the UUID was not found
            callbackError(uuid+" not exists in session table");
            return;
        }
        callbackSuccess(res);
    });

I checked DB then data have updated but result:
info: command=null, rowCount=null, oid=null, rows=[], fields=[], _parsers=[], RowCtor=null

Why rowCount is null while data is updated in DB?

Please, help me

@datcatloi datcatloi changed the title from Update/Insert posgres to error when Update/Insert postgres Apr 1, 2014

Owner

grncdr commented Apr 7, 2014

Hey sorry for not responding to this issue earlier, I'm in the middle of a big move so I've been pretty busy. In your code sample above you are checking res.rows.affectedRows where you should be checking res.affectedRows, that being said I'm not sure if pg-query-stream sets the same properties. I will have to look into it more deeply when I get some free time.

I'm also seeing an issue where code to do an update command used to return a result object with a rowCount numeric property, and I updated to the latest any-db-postgres and now the result object is all null/empty values same as @datcatloi indicated above. The update does work correctly at the DB level, but the API for getting the rowCount seems to now have a bug.

hello @focusaurus , t think so, this ploblem is that when it commit transaction but it dont return objects(effect record).

My skype: dat.catloi
Please, add my skype to chat, thanks

Owner

grncdr commented Jul 13, 2014

I've just pushed a commit to master that restores row-counts (issue was that pg-query-stream doesn't add this information to it's _result property, because it doesn't expect you to use it).

Please test out master and let me know if your issue has been fixed, and I will push a new release to npm

@grncdr grncdr closed this in c0764dc Jul 13, 2014

Hitting an exception that I think is unrelated and is maybe a discrepancy in the pg module comparing the package.json between the github source and what arrives via npm. Once I track that down I can easily confirm whether or not the fix resolves this issue for me.

Owner

grncdr commented Jul 13, 2014

ok, let me know if I can help with that.

It's issue 9 in pg.js if you want to have a look, but I think the fix is for pg.js to fix it's package.json file.

Yup, confirm this fix now. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment