qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.43k stars 2.99k forks source link

dataProvider().addFeatures() message error "too many attributes" for MySQL data #31227

Open efac-fb opened 5 years ago

efac-fb commented 5 years ago

Describe the bug I created a plugin that allows to create an entity in an existing MySQL database using pyqgis dataProvider().addFeatures([feature]) The plugin worked very well on QGIS 2.X and when upgrading to version 3.X an error message appears each time an entity is created: "the object has too many attributes". I think this bug report is similar: #18784 the error appears even if the layer has no virtual field.

How to Reproduce

  1. Add a layer in an existing MySQL database
  2. Create a feature using pyqgis dataProvider().addFeatures()
  3. See error "feature has too many attributes"

QGIS and OS versions OS version : Windows Server 2016 (1607)

Version de QGIS 3.4.10-Madeira Révision du code 3d97aaae88 Compilé avec Qt 5.11.2 Utilisant Qt 5.11.2 Compilé avec GDAL/OGR 2.4.1 Utilisé avec GDAL/OGR 2.4.1 Compilé avec GEOS 3.7.2-CAPI-1.11.0 Utilisé avec GEOS 3.7.2-CAPI-1.11.0 b55d2125 Version du client PostgreSQL 9.2.4 SpatiaLite Version 4.3.0 Version de QWT 6.1.3 Version de QScintilla2 2.10.8 Compilé avec PROJ 520 Fonctionne avec PROJ 5.2.0

nyalldawson commented 5 years ago

Possibly silly question - but DOES your feature have more attributes then the data provider's field count?

efac-fb commented 5 years ago

I checked several times, the number of attributes is correct. Even if the number of attributes is less than the data provider's field count, the error appears.

I forgot to mention that the object is well created in the database, despite the message.

roya0045 commented 5 years ago

From what I see, this error is only in the memory provider and could not come from the mssql provider.