mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
Merge pull request #523 from bartlomiej-korpus/github-issue-521
fix #521 related to typo in QB
This commit is contained in:
commit
c5a35d04a4
@ -1405,7 +1405,7 @@ export class QueryBuilder<Entity> {
|
||||
const updateSet = Object.keys(this.expressionMap.updateSet).map(key => key + "=:updateSet__" + key);
|
||||
const params = Object.keys(this.expressionMap.updateSet).reduce((object, key) => {
|
||||
// todo: map propertyNames to names ?
|
||||
object["updateSet_" + key] = this.expressionMap.updateSet![key];
|
||||
object["updateSet__" + key] = this.expressionMap.updateSet![key];
|
||||
return object;
|
||||
}, {} as ObjectLiteral);
|
||||
this.setParameters(params);
|
||||
|
||||
12
test/github-issues/521/entity/Car.ts
Normal file
12
test/github-issues/521/entity/Car.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Entity } from "../../../../src/decorator/entity/Entity";
|
||||
import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn";
|
||||
import { Column } from "../../../../src/decorator/columns/Column";
|
||||
|
||||
@Entity()
|
||||
export class Car {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
name: string;
|
||||
}
|
||||
32
test/github-issues/521/issue-521.ts
Normal file
32
test/github-issues/521/issue-521.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import "reflect-metadata";
|
||||
import {createTestingConnections, closeTestingConnections, reloadTestingDatabases} from "../../utils/test-utils";
|
||||
import {Connection} from "../../../src/connection/Connection";
|
||||
import {expect} from "chai";
|
||||
import {Car} from "./entity/Car";
|
||||
|
||||
describe("github issues > #521 Attributes in UPDATE in QB arent getting replaced", () => {
|
||||
|
||||
let connections: Connection[];
|
||||
before(async () => connections = await createTestingConnections({
|
||||
entities: [__dirname + "/entity/*{.js,.ts}"],
|
||||
schemaCreate: true,
|
||||
dropSchemaOnConnection: true,
|
||||
}));
|
||||
beforeEach(() => reloadTestingDatabases(connections));
|
||||
after(() => closeTestingConnections(connections));
|
||||
|
||||
it("should replace parameters", () => Promise.all(connections.map(async connection => {
|
||||
|
||||
const qb = connection.getRepository(Car).createQueryBuilder("car");
|
||||
const [query, parameters] = qb
|
||||
.update({
|
||||
name: "Honda",
|
||||
})
|
||||
.where("name = :name", {
|
||||
name: "Toyota",
|
||||
})
|
||||
.getSqlWithParameters();
|
||||
return parameters.length.should.eql(2);
|
||||
})));
|
||||
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user