-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
- Loading branch information
Showing
3 changed files
with
58 additions
and
2 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,17 @@ | ||
import { UpdateDateColumn } from "../../../../src"; | ||
import {Entity} from "../../../../src/decorator/entity/Entity"; | ||
import {PrimaryGeneratedColumn} from "../../../../src/decorator/columns/PrimaryGeneratedColumn"; | ||
import {Column} from "../../../../src/decorator/columns/Column"; | ||
|
||
@Entity() | ||
export class Post { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column() | ||
title: string; | ||
|
||
@UpdateDateColumn({ type: "timestamptz" }) | ||
updatedAt: Date; | ||
|
||
} |
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,36 @@ | ||
import "reflect-metadata"; | ||
import { expect } from "chai"; | ||
import {createTestingConnections, closeTestingConnections, reloadTestingDatabases} from "../../utils/test-utils"; | ||
import {Connection} from "../../../src/connection/Connection"; | ||
import {Post} from "./entity/Post"; | ||
|
||
describe.only("github issues > #2651 set shouldn't have update statements twice when UpdateDate is in use", () => { | ||
|
||
let connections: Connection[]; | ||
before(async () => connections = await createTestingConnections({ | ||
entities: [__dirname + "/entity/*{.js,.ts}"], | ||
enabledDrivers: ["postgres"] | ||
})); | ||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it.only("should add and remove relations of an entity if given a mix of ids and objects", () => Promise.all(connections.map(async connection => { | ||
|
||
const post1 = new Post(); | ||
post1.title = "post #1"; | ||
await connection.manager.save(post1); | ||
|
||
// within this issue update was failing | ||
await connection.manager.update(Post, { | ||
id: 1 | ||
}, { | ||
title: "updated post", | ||
updatedAt: new Date() | ||
}); | ||
|
||
const loadedPost1 = await connection.manager.findOneOrFail(Post, { id: 1 }); | ||
expect(loadedPost1.title).to.be.eql("updated post"); | ||
|
||
}))); | ||
|
||
}); |