-
-
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: datetime functions in column "default" leads to unnecessary quer…
…ies during synchronization (#7517) * fix #3991 * fix #3991 * improved test for #2737; fixed remaining issues in #2737; * fix #6412 * added test for #4281 and #4658 * fixed `NOW()` function usage in MySQL/MariaDB; fixed precision in datetime functions for MySQL/MariaDB; improved #3991 test for MySQL/MariaDB; * added test for #2333 * added test for #7381 * added "remove" operation check in #4658 test * fixed precision in datetime functions for PostgreSQl; improved #3991 test for PostgreSQl; * improved #3991 test for CockroachDB; * improved #3991 test for Sqlite; * improved #3991 test for Oracle and SQLServer;
- Loading branch information
1 parent
0595d23
commit 03f3285
Showing
25 changed files
with
1,040 additions
and
52 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
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
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,12 @@ | ||
import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src"; | ||
|
||
@Entity("test") | ||
export class Test { | ||
|
||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column({ type: "datetime", nullable: true, default: null }) | ||
publish_date: 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,27 @@ | ||
import {Connection} from "../../../src"; | ||
import {closeTestingConnections, createTestingConnections} from "../../utils/test-utils"; | ||
import {Test} from "./entity/Test"; | ||
|
||
describe("github issues > #2333 datetime column showing changed on every schema:sync run", () => { | ||
let connections: Connection[]; | ||
before(async () => connections = await createTestingConnections({ | ||
enabledDrivers: ["mysql", "mariadb"], | ||
schemaCreate: false, | ||
dropSchema: true, | ||
entities: [Test], | ||
})); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("should recognize model changes", () => Promise.all(connections.map(async connection => { | ||
const sqlInMemory = await connection.driver.createSchemaBuilder().log(); | ||
sqlInMemory.upQueries.length.should.be.greaterThan(0); | ||
sqlInMemory.downQueries.length.should.be.greaterThan(0); | ||
}))); | ||
|
||
it("should not generate queries when no model changes", () => Promise.all(connections.map(async connection => { | ||
await connection.driver.createSchemaBuilder().build(); | ||
const sqlInMemory = await connection.driver.createSchemaBuilder().log(); | ||
sqlInMemory.upQueries.length.should.be.equal(0); | ||
sqlInMemory.downQueries.length.should.be.equal(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
Oops, something went wrong.