forked from typeorm/typeorm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Postgres IDENTITY Column support (typeorm#7741)
* feat: extend column options interfaces to also support Postgres10+ Identity generationStrategy * feat: extend PrimaryGeneratedColumn support for Postgres10+ identity * feat: update buildCreateColumnSql with Postgres10+ IDENTITY support * feat: update loadTables for Postgres10+ IDENTITY column recognition * doc: add description of identity support for PrimaryGeneratedColumn * test: add test for SQL of table with IDENTITY COLUMN in Postgres 10+ * feat: take identity generation type into consideration when checking for changed column * fix: better non behavior changing way of checking for identity column * chore: rebase and resolve PR conversations
- Loading branch information
1 parent
ea8fc49
commit 96b3475
Showing
10 changed files
with
66 additions
and
22 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,7 @@ | ||
import { Entity, PrimaryGeneratedColumn } from "../../../../src"; | ||
|
||
@Entity() | ||
export class User { | ||
@PrimaryGeneratedColumn("identity") | ||
id!: number; | ||
} |
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,24 @@ | ||
import "reflect-metadata"; | ||
import { createTestingConnections, closeTestingConnections } from "../../utils/test-utils"; | ||
import { Connection } from "../../../src"; | ||
import { User } from "./entity/UserEntity"; | ||
|
||
import { expect } from "chai"; | ||
|
||
describe("github issues > #5365 Generated Identity for Postgres 10+", () => { | ||
|
||
let connections: Connection[]; | ||
before(async () => connections = await createTestingConnections({ | ||
entities: [User], | ||
schemaCreate: false, | ||
dropSchema: true, | ||
enabledDrivers: ["postgres"], | ||
})); | ||
after(() => closeTestingConnections(connections)); | ||
it("should produce proper SQL for creating a table with identity column", () => Promise.all(connections.map(async connection => { | ||
const sqlInMemory = await connection.driver.createSchemaBuilder().log(); | ||
expect(sqlInMemory).to.have.property("upQueries").that.is.an("array").and.has.length(1); | ||
expect(sqlInMemory.upQueries[0]).to.have.property("query").that | ||
.eql(`CREATE TABLE "user" ("id" integer GENERATED BY DEFAULT AS IDENTITY NOT NULL, CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))`); | ||
}))); | ||
}); |