Skip to content

Commit

Permalink
feat: UpdateResult returns affected rows in mysql (#5628)
Browse files Browse the repository at this point in the history
Set 'affected' property for 'UpdateResult' returned by MySQL

Closes: #1308
  • Loading branch information
weeix committed Mar 11, 2020
1 parent 76e165d commit 17f2fff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/query-builder/UpdateQueryBuilder.ts
Expand Up @@ -104,6 +104,10 @@ export class UpdateQueryBuilder<Entity> extends QueryBuilder<Entity> implements
updateResult.raw = result[0];
updateResult.affected = result[1];
}
else if (this.connection.driver instanceof MysqlDriver) {
updateResult.raw = result;
updateResult.affected = result.affectedRows;
}
else {
updateResult.raw = result;
}
Expand Down
2 changes: 1 addition & 1 deletion test/github-issues/1308/issue-1308.ts
Expand Up @@ -11,7 +11,7 @@ describe("github issues > #1308 Raw Postgresql Update query result is always an
(connections = await createTestingConnections({
entities: [new EntitySchema<Author>(AuthorSchema), new EntitySchema<Post>(PostSchema)],
dropSchema: true,
enabledDrivers: ["postgres"],
enabledDrivers: ["postgres", "mysql", "mariadb"],
}))
);
beforeEach(() => reloadTestingDatabases(connections));
Expand Down

0 comments on commit 17f2fff

Please sign in to comment.