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: unnecessary migrations for unsigned numeric types (typeorm#6632)
* fix: Unnecessary migrations for unsigned numeric types In MariaDB, unsigned numeric types (``<tiny,small,medium>int`) without an explicit `width` property set would generate migrations on every run. This is due to an error in setting the default width for unsigned types. Fixes typeorm#2943 * test: Enable all tests * refactor: Move isDefaultColumnWidth() method out of BaseQueryRunner See typeorm#6632 (review) for discussion as to why. * fix: Correct unsigned int behaviour for MySQL 5.7 * fix: Correct position of zerofill check Plus stylistic change based on code review
- Loading branch information
1 parent
2615fcf
commit d5cc432
Showing
5 changed files
with
106 additions
and
23 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,22 @@ | ||
import { Column, Entity, PrimaryColumn } from "../../../../src"; | ||
|
||
@Entity() | ||
export class Test { | ||
@PrimaryColumn() | ||
id: number; | ||
|
||
@Column({ type: 'int', unsigned: true}) | ||
uInt: number; | ||
|
||
@Column({ type: 'tinyint', unsigned: true}) | ||
uTinyInt: number; | ||
|
||
@Column({ type: 'smallint', unsigned: true}) | ||
uSmallInt: number; | ||
|
||
@Column({ type: 'mediumint', unsigned: true}) | ||
uMediumInt: number; | ||
|
||
@Column({ type: 'bigint', unsigned: true}) | ||
uBigInt: 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,29 @@ | ||
import "reflect-metadata"; | ||
import { expect } from "chai"; | ||
import { Connection } from "../../../src"; | ||
import { closeTestingConnections, createTestingConnections, reloadTestingDatabases } from "../../utils/test-utils"; | ||
import { Test } from "./entity/Test"; | ||
|
||
describe("github issues > #2943 Inappropriate migration generated", () => { | ||
|
||
let connections: Connection[]; | ||
|
||
before(async () => { | ||
connections = await createTestingConnections({ | ||
enabledDrivers: ['mariadb', 'mysql'], | ||
entities: [Test], | ||
schemaCreate: true, | ||
dropSchema: true | ||
}); | ||
}); | ||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("should not create migrations for unsigned numeric types with no specified width", () => | ||
Promise.all(connections.map(async (connection) => { | ||
const sqlInMemory = await connection.driver.createSchemaBuilder().log(); | ||
|
||
expect(sqlInMemory.upQueries).to.eql([]); | ||
expect(sqlInMemory.downQueries).to.eql([]); | ||
}))); | ||
}); |