Skip to content

Commit 9b49fc9

Browse files
authored
Merge pull request #203 from strongloop/affectedRows
Use unique param for affectedRows
2 parents a7c22cf + ac8d0e4 commit 9b49fc9

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/postgresql.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ PostgreSQL.prototype.executeSQL = function(sql, params, options, callback) {
153153
switch (data.command) {
154154
case 'DELETE':
155155
case 'UPDATE':
156-
result = {count: data.rowCount};
156+
result = {affectedRows: data.rowCount, count: data.rowCount};
157157
break;
158158
default:
159159
result = data.rows;
@@ -520,7 +520,7 @@ PostgreSQL.prototype.getPlaceholderForValue = function(key) {
520520
};
521521

522522
PostgreSQL.prototype.getCountForAffectedRows = function(model, info) {
523-
return info && info.count;
523+
return info && info.affectedRows;
524524
};
525525

526526
require('./discovery')(PostgreSQL);

test/postgresql.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@ describe('postgresql connector', function() {
9090
});
9191
});
9292

93+
it('should preserve property `count` after query execution', function(done) {
94+
Post.create(
95+
{title: 'T10', content: 'C10'},
96+
function(err, p) {
97+
if (err) return done(err);
98+
post = p;
99+
var query = "UPDATE PostWithBoolean SET title ='T20' WHERE id=" + post.id;
100+
db.connector.execute(query, function(err, results) {
101+
results.should.have.property('count', 1);
102+
results.should.have.property('affectedRows', 1);
103+
done(err);
104+
});
105+
});
106+
});
107+
93108
it('should support updating boolean types with false value', function(done) {
94109
Post.update({id: post.id}, {approved: false}, function(err) {
95110
should.not.exists(err);

0 commit comments

Comments
 (0)