Skip to content

Commit b343a39

Browse files
author
Loay Gewily
committed
Add unit test
1 parent d7548fc commit b343a39

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/postgresql.js

Lines changed: 1 addition & 1 deletion
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 = {affectedRows: data.rowCount};
156+
result = {affectedRows: data.rowCount, count: data.rowCount};
157157
break;
158158
default:
159159
result = data.rows;

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 reserve property `count` after query execution', function(done) {
94+
Post.create(
95+
{title: 'T10', content: 'C10'},
96+
function(err, p) {
97+
should.not.exists(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)