Bug report #19578
MSSQL: Setting geometry type to "Polygon" makes layer unselectable
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Data Provider/MSSQL | ||
Affected QGIS version: | 3.2.1 | Regression?: | No |
Operating System: | Windows 10 | Easy fix?: | Yes |
Pull Request or Patch supplied: | No | Resolution: | fixed/implemented |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 27405 |
Description
In QGIS 3.2.1 on Windows 10, when attempting to add an empty layer from a SQL Server database using the Data Source Manager, the table's entry in the dialog becomes unselectable if its geometry type is set to "Polygon". As a result, the layer cannot be added.
No other geometry type seems to be affected.
To reproduce:
- Create a basic table in SQL Server like the following. Importantly, do not add any records to the table, so the geometry type cannot be inferred by QGIS.
CREATE TABLE [dbo].[Polygon] ( [PolygonID] [int] IDENTITY(1, 1) NOT NULL, [Shape] [geometry] )
- In QGIS, open the Data Source Manager (Ctrl-L), select "MSSQL" from the list on the left and connect to the database containing the table just created.
- In the list of tables that appears, set the "Polygon" table's SRID to "4326" and its geometry type to "Polygon".
- Attempt to select the table and add it to the project.
The issue appears to be a disagreement in the code on the meaning of the "Type" combo box's value: QgsMssqlSourceSelectDelegate::createEditor()
populates it with values from the QgsWkbTypes::Type
enum, while QgsMssqlTableModel::setData()
interprets its value as belonging to the QgsWkbTypes::GeometryType
enum. And since the value of QgsWkbTypes::Polygon
happens to equal that of QgsWkbTypes::UnknownGeometry
, setData()
makes the table's entry unselectable when the "Polygon" type is selected in the UI.
This is probably the result of an edit accidentally left out of commit 4945611, which changed the enum used by QgsMssqlSourceSelectDelegate::createEditor()
.
I'll submit a pull request shortly.
Associated revisions
[MSSQL] Correctly interpret geometry-type setting
Interpret a table's geometry type (as selected in the Data Source Manager) as a
value from the QgsWkbTypes::Type enum, matching the values used to populate the
combo box in QgsMssqlSourceSelectDelegate::createEditor().
This allows an empty table whose geometry type is set to "Polygon" to be
selected and added using the dialog.
Fixes #19578.
[MSSQL] Correctly interpret geometry-type setting
Interpret a table's geometry type (as selected in the Data Source Manager) as a
value from the QgsWkbTypes::Type enum, matching the values used to populate the
combo box in QgsMssqlSourceSelectDelegate::createEditor().
This allows an empty table whose geometry type is set to "Polygon" to be
selected and added using the dialog.
Fixes #19578.
(cherry-picked from a9ca69b7)
History
#1 Updated by Simon South over 6 years ago
I've submitted pull request 7583 to fix this.
#2 Updated by Simon South over 6 years ago
- % Done changed from 0 to 100
- Status changed from Open to Closed
Applied in changeset qgis|a9ca69b7685249b41843b892389c06d52c3326ca.
#3 Updated by Giovanni Manghi over 6 years ago
- Resolution set to fixed/implemented