Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
in #4958 we found that the PR #4804 caused issues in a variety of situations. this adds a test to prevent the issue from recurring where similar classes get mixed up in our metadata resolver
- Loading branch information
1 parent
990442e
commit 4a0faf0
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Column, Entity } from "../../../../src"; | ||
|
||
@Entity({ name: "first" }) | ||
export default class Testing { | ||
@Column("int", { | ||
nullable: false, | ||
primary: true, | ||
unique: true, | ||
}) | ||
public id!: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Column, Entity } from "../../../../src"; | ||
|
||
@Entity({ name: "second" }) | ||
export default class Testing { | ||
@Column("int", { | ||
nullable: false, | ||
primary: true, | ||
unique: true, | ||
}) | ||
public notId!: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {expect} from "chai"; | ||
import {Connection} from "../../../src/connection/Connection"; | ||
import {closeTestingConnections, createTestingConnections, reloadTestingDatabases} from "../../utils/test-utils"; | ||
import First from "./entity/first"; | ||
import Second from "./entity/second"; | ||
|
||
describe("github issues > #4958 getRepository returns results from another Repo", () => { | ||
let connections: Connection[]; | ||
before(async () => connections = await createTestingConnections({ | ||
entities: [First, Second], | ||
enabledDrivers: ["sqlite"] | ||
})); | ||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("sql generated is for correct model", () => Promise.all(connections.map(async connection => { | ||
const rawSql = await connection | ||
.getRepository(Second) | ||
.createQueryBuilder("a") | ||
.getSql(); | ||
|
||
expect(rawSql).to.be.equal('SELECT "a"."notId" AS "a_notId" FROM "second" "a"'); | ||
}))); | ||
}); |