forked from typeorm/typeorm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Unknown fields are stripped from WHERE clause (issue typeorm#3416)…
… (typeorm#5603) * fix: Unknown fields are stripped from WHERE clause (issue typeorm#3416) * update non-exist columns test
- Loading branch information
1 parent
9241746
commit e475440
Showing
8 changed files
with
126 additions
and
83 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,17 @@ | ||
import {Entity} from "../../../../src/decorator/entity/Entity"; | ||
import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn"; | ||
import {Column} from "../../../../src/decorator/columns/Column"; | ||
|
||
@Entity() | ||
export class User { | ||
|
||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column() | ||
name: string; | ||
|
||
@Column() | ||
likesCount: number = 0; | ||
|
||
} |
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,47 @@ | ||
import "reflect-metadata"; | ||
import { expect } from "chai"; | ||
import { closeTestingConnections, createTestingConnections, reloadTestingDatabases } from "../../utils/test-utils"; | ||
import { Connection } from "../../../src/connection/Connection"; | ||
import {User} from "../../functional/query-builder/update/entity/User"; | ||
import {EntityColumnNotFound} from "../../../src/error/EntityColumnNotFound"; | ||
|
||
describe("github issues > #3416 Unknown fields are stripped from WHERE clause", () => { | ||
|
||
let connections: Connection[]; | ||
before(async () => connections = await createTestingConnections({ | ||
entities: [User] | ||
})); | ||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
describe("should throw EntityColumnNotFound when supplying unknown property in where criteria", () => { | ||
it("find", () => Promise.all(connections.map(async connection => { | ||
let error: Error | undefined; | ||
try { | ||
// @ts-ignore | ||
await connection.manager.findOne(User, {unknownProp: "John Doe"}); | ||
} catch (err) { | ||
error = err; | ||
} | ||
expect(error).to.be.an.instanceof(EntityColumnNotFound); | ||
}))); | ||
it("update", () => Promise.all(connections.map(async connection => { | ||
let error: Error | undefined; | ||
try { | ||
await connection.manager.update(User, { unknownProp: "Something" }, { name: "John doe "}); | ||
} catch (err) { | ||
error = err; | ||
} | ||
expect(error).to.be.an.instanceof(EntityColumnNotFound); | ||
}))); | ||
it("delete", () => Promise.all(connections.map(async connection => { | ||
let error: Error | undefined; | ||
try { | ||
await connection.manager.delete(User, { unknownProp: "Something" }); | ||
} catch (err) { | ||
error = err; | ||
} | ||
expect(error).to.be.an.instanceof(EntityColumnNotFound); | ||
}))); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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