Bug report #8480

"The attribute could not be inserted. The name already exists in the table." when adding a real or double column in PostGIS

Added by Giovanni Manghi about 6 years ago. Updated about 6 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:Data Provider/PostGIS
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:17247

Description

Every time I try to add a "real" or "double" type of column in a PostGIS layer now QGIS returns

The attribute could not be inserted. The name already exists in the table.

even when the name does not exist in the table.

With other types no issues.

Tested on master on both Windows and Linux.

Associated revisions

Revision 22eec4af
Added by Matthias Kuhn about 6 years ago

Set min field precision even when hidden (Fix #8480)

History

#1 Updated by Salvatore Larosa about 6 years ago

  • Assignee set to Marco Hugentobler

it looks like if precision (mPrec) is not set properly when not visible and reverting the 69c656e solves the issue.

Clearly pure imagination to me but I think Marco can quickly solve this problem. :-)

#2 Updated by Salvatore Larosa about 6 years ago

I forgot to say....

For me the message is simply "Attribute Error: The attribute could not be added to the layer".

#3 Updated by Salvatore Larosa about 6 years ago

I think of having (almost) track out the issue. :-)

I noticed that applying the following patch fix the problem:

diff --git a/src/providers/postgres/qgspostgresprovider.cpp b/src/providers/postgres/qgspostgresprovider.cpp
index 9319498..64ccfef 100644
--- a/src/providers/postgres/qgspostgresprovider.cpp
+++ b/src/providers/postgres/qgspostgresprovider.cpp
@@ -164,8 +164,8 @@ QgsPostgresProvider::QgsPostgresProvider( QString const & uri )
   << QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "decimal", QVariant::Double, 1, 20, 0, 20 )

   // floating point
-  << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double, -1, -1, -1, -1 )
-  << QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double precision", QVariant::Double, -1, -1, -1, -1 )
+  << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double )
+  << QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double precision", QVariant::Double )

   // string types
   << QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), "char", QVariant::String, 1, 255 )

but this patch reverts partially the f20310.
In my tests I can confirm that the #8145 remains solved, but when a new field is created by field calculator I see the message bar with the message like in #8481.

So, my conclusion is: just reverting Marco's commit solve this issue and #8481.

#4 Updated by Salvatore Larosa about 6 years ago

  • Assignee deleted (Marco Hugentobler)

off road and wrong conclusion, sorry!

#5 Updated by Matthias Kuhn about 6 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF