4

I have just ran into an issue with QGIS/PostGIS. Here is a summary of my problem:

  1. I have uploaded a world country boundaries shapefile as a PostGIS table to my database.
  2. I add the new PostGIS table to QGIS as a layer.
  3. I toggle editing for the table so that I may edit the file.
  4. I click on "New Field" and enter "test" as the field name, leaving everything else default.
  5. I click "OK" and the following error message pops up: "Failed to add field 'test' of type 'int2'. Is the field name unique?"
  6. There is no other field named "test", and no other field name works.

All the googling I have done on SE/SO and this sub have left me empty handed. Does anyone have an idea as to why I cannot add a field to this PostGIS table?

At first I thought it may have been a privilege issue with Postgres but I double checked the login role that I used has insert/update/delete privileges. Additionally, I connected to the database using the superuser credentials and had the same issue. For reference, I am using QGIS 2.18.9 with Win7 x64.

Also, some additional information: When I toggle editing for the table, the "Delete field" button is still grayed out, which I thought was odd as usually that button is usable when editing is toggled on. Not sure if that's helpful or not.

0

1 Answer 1

2

I faced a similar situation in QGIS where I could add new features and save them, but adding or deleting new fields weren't possible. It turned our that my logged in user in QGIS had permissions for reading/writing etc, but the owner of the table was a different user. Changing ownership of the table in PgAdmin to the QGIS user solved the issue.

1
  • I was facing the same issue, thanks. The QGIS error statement itself is misleading Feb 22 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.