Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for Postgres 10+ GENERATED ALWAYS AS IDENTITY #8371

Merged

Conversation

leoromanovsky
Copy link
Contributor

@leoromanovsky leoromanovsky commented Nov 16, 2021

allow developers to create a generated PrimaryGeneratedColumn or Column of identity
and choose between ALWAYS and BY DEFAULT.

Relevant documentation: https://www.postgresql.org/docs/10/sql-createtable.html

I am motivated to build on the work in (#7741) and provide both of the supported Postgres 10+ options; arguably using the ALWAYS option will be more widely adopted. Additionally expanding the capability to using identity on any Column, not just primary.

Closes: #8370

Description of change

The underlying goal of the PR was to enable PostgresQueryRunner.ts to be able to decide which of the generated identity types to create.

I wanted to add the minimal amount of code to support that.

  • The PrimaryGeneratedColumnIdentityOptions is needed to be able to pass information not encapsulated by the previously used UUIDOptions

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run lint passes with this change
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions explained in CONTRIBUTING.md

@leoromanovsky leoromanovsky force-pushed the lromanovsky/postgres-identity-always branch 4 times, most recently from fb4af30 to 8eebdad Compare November 22, 2021 09:17
@leoromanovsky leoromanovsky marked this pull request as ready for review November 22, 2021 09:32
allow developers to create a Column of identity
and choose between `ALWAYS` and `BY DEFAULT`.

Closes: typeorm#8370
@leoromanovsky leoromanovsky force-pushed the lromanovsky/postgres-identity-always branch from fd75a65 to 2425e7e Compare November 22, 2021 10:17
@pleerock pleerock merged commit a0f09de into typeorm:master Nov 23, 2021
@pleerock
Copy link
Member

Thanks for the hard work!

@leoromanovsky leoromanovsky deleted the lromanovsky/postgres-identity-always branch November 24, 2021 08:03
HeartPattern pushed a commit to HeartPattern/typeorm that referenced this pull request Nov 29, 2021
…orm#8371)

allow developers to create a Column of identity
and choose between `ALWAYS` and `BY DEFAULT`.

Closes: typeorm#8370
HeartPattern pushed a commit to HeartPattern/typeorm that referenced this pull request Nov 29, 2021
…orm#8371)

allow developers to create a Column of identity
and choose between `ALWAYS` and `BY DEFAULT`.

Closes: typeorm#8370
@mdurling
Copy link

mdurling commented Jan 5, 2022

Thanks for the hard work!

Any timeframe on getting a new release containing this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Postgres GENERATED ALWAYS AS IDENTITY
3 participants