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

Copying fetures to PostgreSQL layer not copying same name attribute value #51121

Closed
2 tasks done
ar-siddiqui opened this issue Dec 5, 2022 · 1 comment
Closed
2 tasks done
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PostGIS data provider Won't fix By design, or won't be fixed for some other reason

Comments

@ar-siddiqui
Copy link

ar-siddiqui commented Dec 5, 2022

What is the bug or the crash?

I have a GPKG layer which has source data, one of the columns is 'name' string datatype. I am trying to copy features from it to a PSQL table which also has column 'name' varchar datatype. Features are copying fine but the column 'name' value is not copying over.

This is not the case if you copy to any other format.

Steps to reproduce the issue

  1. Create PSQL table
CREATE SCHEMA modeling_domains;
CREATE TABLE modeling_domains.hucs (
    name VARCHAR (12) NOT NULL PRIMARY KEY,
    geom geometry(POLYGON, 3857)
);
  1. Copy all features from the attached gpkg to the SQL table. source.zip

  2. 'name' column would not carry over.

Versions

Checked in both 3.28 and 3.22

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

No response

@ar-siddiqui ar-siddiqui added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Dec 5, 2022
@troopa81 troopa81 self-assigned this Feb 8, 2023
@troopa81
Copy link
Contributor

troopa81 commented Feb 8, 2023

It's because name field is a primary key and is regenerated to avoid fid collision.

You can add a serial PRIMARY KEY not based on name and add the UNIQUE constraint on name.

This is the intended behavior, see #42511

@troopa81 troopa81 closed this as completed Feb 8, 2023
@troopa81 troopa81 added the Won't fix By design, or won't be fixed for some other reason label Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PostGIS data provider Won't fix By design, or won't be fixed for some other reason
Projects
None yet
Development

No branches or pull requests

3 participants