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: Migration issues with scale & precision in sqlite/sql.js (typeor…
…m#6638) * fix: Migration issues with scale & precision in sqlite/sql.js Specifying precision or scale properties on columns with SQLite/sql.js would result in migrations being generated even on an unchanged schema. This was due to the precision and scale arguments not correctly being inferred when reading the table. This change handles scale and precision in the same way that "length" was already being correctly handled. Fixes typeorm#6636 * awaited the test * fix missing async Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
- Loading branch information
1 parent
c8368c1
commit dab11c7
Showing
4 changed files
with
78 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Column, Entity, PrimaryColumn } from "../../../../src"; | ||
|
||
@Entity() | ||
export class Test { | ||
|
||
@PrimaryColumn() | ||
id: number; | ||
|
||
@Column({ nullable: true, precision: 6 }) | ||
startedAt?: Date; | ||
|
||
@Column({ type: 'decimal', precision: 5, scale: 2 }) | ||
value: number; | ||
|
||
} |
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,25 @@ | ||
import { Connection } from "../../../src"; | ||
import { closeTestingConnections, createTestingConnections, reloadTestingDatabases } from "../../utils/test-utils"; | ||
import { Test } from "./entity/Test"; | ||
import { expect } from "chai"; | ||
|
||
describe("github issues > #6636 migration issues with scale & precision", () => { | ||
|
||
let connections: Connection[]; | ||
before(async () => connections = await createTestingConnections({ | ||
entities: [Test], | ||
enabledDrivers: ["sqljs", "sqlite", "better-sqlite3"], | ||
})); | ||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("should not create migrations columns with precision", async () => { | ||
await Promise.all(connections.map(async (connection) => { | ||
const sqlInMemory = await connection.driver.createSchemaBuilder().log(); | ||
expect(sqlInMemory.upQueries).to.eql([]); | ||
expect(sqlInMemory.downQueries).to.eql([]); | ||
} | ||
)) | ||
}); | ||
|
||
}); |