Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit bc29597

Browse files
wy193777AlexMesser
andauthored
test: Got "Index contains column that is missing in the entity" Error even the column is there (typeorm#6754)
* add tests related to my issue * remove unnecessary files * change test description * Update issue-6752.ts added .skip Co-authored-by: AlexMesser <[email protected]>
1 parent fc55277 commit bc29597

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import {
2+
Column, Entity, Index, OneToMany, PrimaryGeneratedColumn,
3+
} from "../../../../src";
4+
import { PlanOfRecord } from "./PlanOfRecord";
5+
6+
// @Entity({ synchronize: false })
7+
@Entity({ synchronize: true })
8+
@Index(["chip_name", "manual", "frequency", "mode"], { unique: true })
9+
export class Block {
10+
@PrimaryGeneratedColumn()
11+
public id?: number;
12+
13+
@Column()
14+
@Index()
15+
public chip_name: string;
16+
17+
@Column()
18+
@Index()
19+
public manual: string;
20+
21+
@Column()
22+
@Index()
23+
public block: string;
24+
25+
@Column()
26+
@Index()
27+
public frequency: string;
28+
29+
@Column()
30+
@Index()
31+
public mode: string;
32+
33+
@OneToMany((type) => PlanOfRecord, (por) => por.block)
34+
public plan_of_records: PlanOfRecord[];
35+
}
36+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {
2+
Check, Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn,
3+
} from "../../../../src";
4+
import { Block } from "./Block";
5+
6+
// @Entity({ synchronize: false })
7+
@Entity({ synchronize: true })
8+
@Index(["block", "softwareComponent", "module", "module_sku ", "isSafety"], { unique: true })
9+
// Enable sync will sometimes cause planOfRecord column become null
10+
@Check(`"planOfRecord" IN ('NOT_POR', 'POR_BUT_PROD_VAL', 'POR_BUT_RESET_VAL')`)
11+
export class PlanOfRecord {
12+
@PrimaryGeneratedColumn()
13+
public id?: number;
14+
15+
@Column()
16+
@Index()
17+
public module: string;
18+
19+
@Column({type: "int"})
20+
@Index()
21+
public module_sku: number;
22+
23+
@Column()
24+
@Index()
25+
public softwareComponent: string;
26+
27+
@Column()
28+
@Index()
29+
public isSafety: boolean;
30+
31+
@Column({nullable: true})
32+
@Index()
33+
public planOfRecord: string;
34+
35+
@Column({nullable: true})
36+
@Index()
37+
public owner: string;
38+
39+
@Column({nullable: true})
40+
public comment: string;
41+
42+
@ManyToOne((type) => Block, (block) => block.plan_of_records)
43+
public block: Block;
44+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import "reflect-metadata";
2+
import {
3+
createTestingConnections,
4+
closeTestingConnections,
5+
reloadTestingDatabases,
6+
} from "../../utils/test-utils";
7+
import { Connection } from "../../../src/connection/Connection";
8+
import { expect } from "chai";
9+
import { Block } from "./entity/Block";
10+
import { PlanOfRecord } from "./entity/PlanOfRecord";
11+
12+
describe.skip("github issues > #6752 column name not been find on unique index decorator", () => {
13+
it("dont change anything", async () => {
14+
let connections: Connection[];
15+
connections = await createTestingConnections({
16+
entities: [Block, PlanOfRecord],
17+
schemaCreate: false,
18+
dropSchema: true,
19+
enabledDrivers: ["mssql"],
20+
});
21+
await reloadTestingDatabases(connections);
22+
await Promise.all(
23+
connections.map(async (connection) => {
24+
const schemaBuilder = connection.driver.createSchemaBuilder();
25+
const syncQueries = await schemaBuilder.log();
26+
expect(syncQueries.downQueries).to.be.eql([]);
27+
expect(syncQueries.upQueries).to.be.eql([]);
28+
})
29+
);
30+
await closeTestingConnections(connections);
31+
});
32+
});

0 commit comments

Comments
 (0)