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: resolves issue with mssql column recreation when length max is i…
…n lower case Closes: typeorm#9399
- Loading branch information
Showing
3 changed files
with
52 additions
and
1 deletion.
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,13 @@ | ||
import { Entity, Generated } from "../../../../src" | ||
import { PrimaryGeneratedColumn } from "../../../../src" | ||
import { Column } from "../../../../src" | ||
|
||
@Entity() | ||
export class ExampleEntity { | ||
@Generated("increment") | ||
@PrimaryGeneratedColumn() | ||
id: number | ||
|
||
@Column({ type: "nvarchar", length: "max" }) | ||
value: string | ||
} |
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,35 @@ | ||
import "reflect-metadata" | ||
import { | ||
createTestingConnections, | ||
closeTestingConnections, | ||
} from "../../utils/test-utils" | ||
import { DataSource } from "../../../src" | ||
import { expect } from "chai" | ||
|
||
describe("github issues > #9399 mssql: Column is dropped and recreated in every migration", () => { | ||
let dataSources: DataSource[] | ||
before( | ||
async () => | ||
(dataSources = await createTestingConnections({ | ||
entities: [__dirname + "/entity/*{.js,.ts}"], | ||
schemaCreate: true, | ||
dropSchema: true, | ||
enabledDrivers: ["mssql"], | ||
})), | ||
) | ||
after(() => closeTestingConnections(dataSources)) | ||
|
||
it("No migration should be created", () => | ||
Promise.all( | ||
dataSources.map(async (dataSource) => { | ||
await dataSource.runMigrations() | ||
const sqlInMemory = await dataSource.driver | ||
.createSchemaBuilder() | ||
.log() | ||
|
||
expect(sqlInMemory.upQueries).to.eql([]) | ||
expect(sqlInMemory.downQueries).to.eql([]) | ||
}), | ||
)) | ||
// you can add additional tests if needed | ||
}) |