mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
* test: #10040 TypeORM synchronize database even if it is up to date * formating * fix: TypeORM synchronize database even if it is up to date #10040
This commit is contained in:
parent
7108cc6f71
commit
b1a3a39504
@ -842,7 +842,10 @@ export class MysqlDriver implements Driver {
|
||||
* fix https://github.com/typeorm/typeorm/issues/1139
|
||||
* note that if the db did support uuid column type it wouldn't have been defaulted to varchar
|
||||
*/
|
||||
if (column.generationStrategy === "uuid" && column.type === "varchar")
|
||||
if (
|
||||
column.generationStrategy === "uuid" &&
|
||||
!this.uuidColumnTypeSuported
|
||||
)
|
||||
return "36"
|
||||
|
||||
switch (column.type) {
|
||||
|
||||
19
test/github-issues/10040/entity/person.ts
Normal file
19
test/github-issues/10040/entity/person.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
} from "../../../../src"
|
||||
import { Todo } from "./todo"
|
||||
|
||||
@Entity({ name: "person" })
|
||||
export class Person {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string
|
||||
|
||||
@Column("varchar")
|
||||
name: string
|
||||
|
||||
@OneToMany(() => Todo, (o) => o.owner)
|
||||
todos: Todo[]
|
||||
}
|
||||
19
test/github-issues/10040/entity/todo.ts
Normal file
19
test/github-issues/10040/entity/todo.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
} from "../../../../src"
|
||||
import { Person } from "./person"
|
||||
|
||||
@Entity({ name: "todo" })
|
||||
export class Todo {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string
|
||||
|
||||
@Column("varchar")
|
||||
description: string
|
||||
|
||||
@ManyToOne(() => Person, (o) => o.todos)
|
||||
owner: Person
|
||||
}
|
||||
33
test/github-issues/10040/issue-10040.ts
Normal file
33
test/github-issues/10040/issue-10040.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { expect } from "chai"
|
||||
import { DataSource } from "../../../src"
|
||||
import {
|
||||
closeTestingConnections,
|
||||
createTestingConnections,
|
||||
reloadTestingDatabases,
|
||||
} from "../../utils/test-utils"
|
||||
import { Person } from "./entity/person"
|
||||
import { Todo } from "./entity/todo"
|
||||
|
||||
describe("github issues > #10040 TypeORM synchronize database even if it is up to date", () => {
|
||||
let dataSources: DataSource[]
|
||||
|
||||
before(async () => {
|
||||
dataSources = await createTestingConnections({
|
||||
entities: [Person, Todo],
|
||||
enabledDrivers: ["mysql"],
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(() => reloadTestingDatabases(dataSources))
|
||||
after(() => closeTestingConnections(dataSources))
|
||||
|
||||
it("should return an empty array for the upQueries after sync", async () => {
|
||||
await Promise.all(
|
||||
dataSources.map(async (dataSource) => {
|
||||
await dataSource.synchronize()
|
||||
const logs = await dataSource.driver.createSchemaBuilder().log()
|
||||
expect(logs.upQueries.length).to.be.eql(0)
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user