Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't escape indexPredicate (#10618)
* fix: don't escape indexPredicate * style: npm run format
- Loading branch information
1 parent
032f535
commit dd49a25
Showing
7 changed files
with
100 additions
and
18 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
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, Index, PrimaryGeneratedColumn } from "../../../../src" | ||
|
||
@Entity() | ||
@Index(["nonNullable", "nullable"], { | ||
unique: true, | ||
where: '"nullable" IS NOT NULL', | ||
}) | ||
export class Example { | ||
@PrimaryGeneratedColumn("uuid") | ||
id?: string | ||
|
||
@Column({ type: "text" }) | ||
nonNullable: string | ||
|
||
@Column({ type: "text", nullable: true }) | ||
nullable: string | null | ||
|
||
@Column({ type: "text" }) | ||
value: 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,44 @@ | ||
import "reflect-metadata" | ||
import { DataSource } from "../../../src" | ||
import { | ||
closeTestingConnections, | ||
createTestingConnections, | ||
reloadTestingDatabases, | ||
} from "../../utils/test-utils" | ||
import { Example } from "./entity/Example" | ||
|
||
describe("github issues > #10191 incorrect escaping of indexPredicate", () => { | ||
let connections: DataSource[] | ||
|
||
before( | ||
async () => | ||
(connections = await createTestingConnections({ | ||
entities: [Example], | ||
enabledDrivers: ["postgres"], | ||
})), | ||
) | ||
beforeEach(() => reloadTestingDatabases(connections)) | ||
after(() => closeTestingConnections(connections)) | ||
|
||
it("should not fail", () => | ||
Promise.all( | ||
connections.map(async (connection) => { | ||
await connection.manager.upsert( | ||
Example, | ||
{ | ||
nonNullable: "nonNullable", | ||
nullable: "nullable", | ||
value: "value", | ||
}, | ||
{ | ||
conflictPaths: { | ||
nonNullable: true, | ||
nullable: true, | ||
}, | ||
skipUpdateIfNoValuesChanged: true, | ||
indexPredicate: '"nullable" IS NOT NULL', | ||
}, | ||
) | ||
}), | ||
)) | ||
}) |
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