mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
fix: resolves issue with mssql column recreation (#9773)
* fix: resolves issue with mssql column recreation when length max is in lower case Closes: #9399 * removed redundant question mark --------- Co-authored-by: ke <ke@sbs.co.at>
This commit is contained in:
parent
cb154d4ca3
commit
07221a3646
@ -1042,7 +1042,10 @@ export class SqlServerDriver implements Driver {
|
||||
// of data type precedence to the expressions specified in the formula.
|
||||
if (columnMetadata.asExpression) return false
|
||||
|
||||
return tableColumn.length !== this.getColumnLength(columnMetadata)
|
||||
return (
|
||||
tableColumn.length.toUpperCase() !==
|
||||
this.getColumnLength(columnMetadata).toUpperCase()
|
||||
)
|
||||
}
|
||||
|
||||
protected lowerDefaultValueIfNecessary(value: string | undefined) {
|
||||
|
||||
13
test/github-issues/9399/entity/ExampleEntity.ts
Normal file
13
test/github-issues/9399/entity/ExampleEntity.ts
Normal file
@ -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
|
||||
}
|
||||
34
test/github-issues/9399/issue-9399.ts
Normal file
34
test/github-issues/9399/issue-9399.ts
Normal file
@ -0,0 +1,34 @@
|
||||
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.length).to.eql(0)
|
||||
expect(sqlInMemory.downQueries.length).to.eql(0)
|
||||
}),
|
||||
))
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user