Skip to content

Commit

Permalink
fix: add missing "comment" field to QB clone method (#7205)
Browse files Browse the repository at this point in the history
Closes: #7203

Co-authored-by: Astrit Shehu <a.shehu@linkplus-ks.com>
  • Loading branch information
astritsh and astrit-shehu committed Dec 22, 2020
1 parent f730bb9 commit f019771
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/query-builder/QueryExpressionMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ export class QueryExpressionMap {
map.callListeners = this.callListeners;
map.useTransaction = this.useTransaction;
map.nativeParameters = Object.assign({}, this.nativeParameters);
map.comment = this.comment;
return map;
}

Expand Down
23 changes: 23 additions & 0 deletions test/github-issues/7203/issue-7203.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {closeTestingConnections, createTestingConnections, reloadTestingDatabases} from "../../utils/test-utils";
import {Connection} from "../../../src/connection/Connection";
import {expect} from "chai";

describe("github issues > #7203 QueryExpressionMap doesn't clone comment field", () => {
let connections: Connection[];
before(
async () =>
(connections = await createTestingConnections({
dropSchema: true,
enabledDrivers: ["postgres"],
}))
);
beforeEach(() => reloadTestingDatabases(connections));
after(() => closeTestingConnections(connections));

it("should be able to clone comment field", () => Promise.all(connections.map(async connection => {
const comment = "a comment";
const queryBuilder = await connection.createQueryBuilder().comment(comment);
const clonedQueryBuilder = queryBuilder.clone();
expect(clonedQueryBuilder.expressionMap.comment).to.be.eq(comment);
})));
});

0 comments on commit f019771

Please sign in to comment.