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
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
- Loading branch information
1 parent
d1ed572
commit 499ebaf
Showing
4 changed files
with
62 additions
and
4 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,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,28 @@ | ||
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.only("github issues > #2932 Inappropriate migration generated", () => { | ||
|
||
let connections: Connection[]; | ||
|
||
before(async () => { | ||
connections = await createTestingConnections({ | ||
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.upQueries.length).to.eq(0); | ||
}))); | ||
}); |