cakephp / cakephp/phinx

Fix setting identity for fetching column information for postgres 9.x

Open
#1,916 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
4.5k
Forks
884
PR merge metrics
No merged PRs in 30d

Description

The postgres adapter when fetching all columns from a table uses this logic to construct the column:

https://github.com/cakephp/phinx/blob/4df3304e11bc0c6e9de4df2eedf733eb9b15cd75/src/Phinx/Db/Adapter/PostgresAdapter.php#L430-L436

The problem here is that $columnInfo['is_identity'] is probably always no for postgres 9.x per its documentation:

is_identity yes_or_no Applies to a feature not available in PostgreSQL

It looks like this feature was added in 10.x. For 9.x, we can probably introduce an alternative scheme where it checks the default and minimally determines that if it is something like nextval('tablename_colname_seq'::regclass), then it is an identity column.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Phinx/Db/Adapter/PostgresAdapter.php around lines 430-436, then compare the PostgreSQL 9.6 information-schema documentation with the current identity-column logic. The work is done when column fetching correctly identifies serial-style identity columns on PostgreSQL 9.x without breaking behavior on newer PostgreSQL versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, postgresql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.