-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle overlapping property / database names in querybuilder (#7042
) we should always prioritize replacement of any property path first, then property names, then database names, then relation values whenever there's ambiguous values fixes #7030
- Loading branch information
1 parent
b35397e
commit b518fa1
Showing
3 changed files
with
82 additions
and
12 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
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,20 @@ | ||
import { Column, Entity, PrimaryGeneratedColumn } from '../../../../src'; | ||
|
||
|
||
@Entity() | ||
export class Post { | ||
|
||
@PrimaryGeneratedColumn({ | ||
type: 'integer', | ||
name: 'id', | ||
}) | ||
oldId: number; | ||
|
||
@Column({ | ||
nullable: false, | ||
unique: true, | ||
length: 38, | ||
name: 'new_id', | ||
}) | ||
id: string; | ||
} |
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,37 @@ | ||
import { expect } from "chai"; | ||
import {Connection} from "../../../src/connection/Connection"; | ||
import { | ||
createTestingConnections, | ||
closeTestingConnections, | ||
reloadTestingDatabases, | ||
} from "../../utils/test-utils"; | ||
import {Post} from "./entity/Post"; | ||
|
||
describe("github issues > #7030", () => { | ||
let connections: Connection[]; | ||
|
||
before(async () => connections = await createTestingConnections({ | ||
entities: [Post], | ||
schemaCreate: true, | ||
dropSchema: true, | ||
enabledDrivers: ["postgres"] | ||
})); | ||
|
||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("should insert and fetch from the expected column", () => Promise.all(connections.map(async connection => { | ||
const id = '123e4567-e89b-12d3-a456-426614174000' | ||
|
||
const post = new Post(); | ||
post.id = id; | ||
|
||
let postRepository = connection.getRepository(Post); | ||
|
||
await postRepository.save(post); | ||
|
||
const actualPost = await postRepository.findOneOrFail({ id }); | ||
|
||
expect(actualPost!.id).to.be.equal(id); | ||
}))); | ||
}); |