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

Unique contraints cause duplicate fields when using postgres #104

Open
jhartwell opened this issue Dec 10, 2019 · 1 comment · May be fixed by #118
Open

Unique contraints cause duplicate fields when using postgres #104

jhartwell opened this issue Dec 10, 2019 · 1 comment · May be fixed by #118
Assignees
Labels
Milestone

Comments

@jhartwell
Copy link
Owner

If you have a column that is a primary key and also has a unique constraint that column will be exported twice in the output. We don't need to worry about the unique constraint so it will need to be ignored

@jhartwell jhartwell added this to the 2.3.2 milestone Dec 10, 2019
@jhartwell jhartwell self-assigned this Dec 10, 2019
@jhartwell jhartwell modified the milestones: 2.3.2, 2.3.3 Dec 10, 2019
@jhartwell jhartwell added the bug label Dec 10, 2019
@tomjoro
Copy link

tomjoro commented Aug 13, 2021

I have traced the issue and have a fix for it (I can make a pull request). The issue is caused by this left join:

        LEFT JOIN pg_index i ON
            (pgc.oid = i.indrelid AND i.indkey[0] = a.attnum)

This causes two effects:

  1. Compound primary keys don't work
  2. If the field is repeated in another index you will get a row for both primary_key: true and primary_key: false (which now generates the field twice).

The solution I have is just to query the primary key(s) in another query otherwise the SQL gets too complicated.

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

Successfully merging a pull request may close this issue.

2 participants