Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow special keyword as column name for simple-enum type on sql…
…ite (#8645) * fix: Allow special keyword as column name for simple-enum type on sqlite * fix: Fix tests * fix: Fix tests
- Loading branch information
1 parent
b93416d
commit 93bf96e
Showing
3 changed files
with
50 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {Column, PrimaryGeneratedColumn} from "../../../../src"; | ||
import {Entity} from "../../../../src/decorator/entity/Entity"; | ||
|
||
export enum Limit { | ||
Foo = "foo", | ||
Bar = "bar", | ||
} | ||
|
||
@Entity() | ||
export class MyTable { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column({ type: "simple-enum", enum: Limit }) | ||
limit: Limit; | ||
} |
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,32 @@ | ||
import { Connection } from "../../../src"; | ||
import { | ||
closeTestingConnections, | ||
createTestingConnections, | ||
reloadTestingDatabases, | ||
} from "../../utils/test-utils"; | ||
import { Limit, MyTable } from "./entity/my-table.entity"; | ||
|
||
describe("github issues > #8644 BUG - Special keyword column name for simple-enum in sqlite", () => { | ||
let connections: Connection[]; | ||
|
||
before( | ||
async () => | ||
(connections = await createTestingConnections({ | ||
entities: [__dirname + "/entity/*{.js,.ts}"], | ||
enabledDrivers: ["sqlite", "better-sqlite3"], | ||
schemaCreate: true, | ||
dropSchema: true, | ||
})) | ||
); | ||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("it should be able to set special keyword as column name for simple-enum types", () => | ||
Promise.all( | ||
connections.map(async (connection) => { | ||
const repository = connection.getRepository(MyTable); | ||
|
||
await repository.insert({ limit: Limit.Bar }); | ||
}) | ||
)); | ||
}); |