Bug report #17423

QGIS select by expression mismatch with MSSQL layers

Added by Solution s over 6 years ago. Updated about 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Data Provider/MSSQL
Affected QGIS version:2.18.14 Regression?:No
Operating System:Windows 7 Enterprise - 32 bit Easy fix?:No
Pull Request or Patch supplied:No Resolution:no timely feedback
Crashes QGIS or corrupts data:No Copied to github as #:25320

Description

When trying to select features using "select by expression", QGIS did select a wrong feature in this case.
I tried on two different days, same result (so I have restarted the PC and QGIS).

What i did was:
  1. Load a layer and select it to use select by expression
  2. Made sure that no features are selected in any layer
  3. Clicked the select by expression button from the toolbar
  4. Put in a very simple criteria: "matrikelnummer" = '10ae'
  5. Clicked select/vælg (see Screenshot_1.png)
  6. In Screenshot_2.png you can see which features QGIS selected in the opened attribute table. As you can see, feature with ID = 8337 (or just line 43) is selected. This should not be selected, because '10ae' != '10an'
    1. Instead it should have selected line 24 (ID = 8339), because as you can see that have '10ae' as the "matrikelnummer"
  7. I also tried to resize the window to see if it was a graphical glitch, no luck.
Interestingly, the layer filter is able to select/filter the correct features.
What i did to further test expressions was:
  1. Deselect all features
  2. Opened up the layer's filter and tested the expression. Correctly returned 2 rows as you can see on Screenshot_3.png
  3. Applied the filter and opened the attribute table. As you can see on Screenshot_4.png the correct features is viewed.
Some information about the layer:
  • The layer is calld Hovedejer matrikel
  • MSSQL spatial data provider
  • srid=25832
  • Polygon (WKB type: "Polygon")
  • (MyGeom)
  • character encoding infomation not available, but since æ, ø, å is displayed correctly, I would guess that it's one that follows this standard: https://en.wikipedia.org/wiki/ISO/IEC_8859-1#Similar_character_sets
    • Interestingly nothing is shown in the layer properties window under "Data Source Encoding", and I'm not able to select any option (there is none).
  • I think the layer is provided by a Microsoft server

Screenshot_1.png - Select by expression window (61 KB) Solution s, 2017-11-08 01:26 PM

Screenshot_2.png - Attribute table with selected features by expression (174 KB) Solution s, 2017-11-08 01:26 PM

Screenshot_3.png - Query Builder/forespørgselsgenerator (68.2 KB) Solution s, 2017-11-08 01:26 PM

Screenshot_4.png - Attribute table with filtered features (31.2 KB) Solution s, 2017-11-08 01:26 PM

History

#1 Updated by Solution s over 6 years ago

Additional layer/field information:
The field "matrikelnummer" type is QString and typename is varchar. Max length 40, precision 0.

#2 Updated by Giovanni Manghi over 6 years ago

  • Status changed from Open to Feedback

Does it happens for other providers (like PostGIS) or datasources? Can you test on a more recent release? Thanks.

#3 Updated by Solution s over 6 years ago

Works fine on this layer:
  • PostgreSQL database with PostGIS extension
  • key='gid'
  • srid=25832
  • type=MultiPolygon

I will try as soon as I get my administrator to update QGIS.

#4 Updated by Giovanni Manghi over 6 years ago

  • Status changed from Feedback to Open
  • Category changed from Expressions to Data Provider/MSSQL

#5 Updated by Giovanni Manghi over 6 years ago

  • Subject changed from QGIS select by expression mismatch to QGIS select by expression mismatch with MSSQL layers

#6 Updated by Solution s over 6 years ago

I uninstalled QGIS 2.18.11 and installed 2.18.14.
I can reproduce the issue on 2.18.14.

#7 Updated by Giovanni Manghi over 6 years ago

  • Affected QGIS version changed from 2.18.11 to 2.18.14

#8 Updated by Nyall Dawson over 5 years ago

  • Status changed from Open to Feedback

Can you provide a SQL dump of part of this layer?

#9 Updated by Jürgen Fischer over 5 years ago

Please test with QGIS 3.4 - QGIS 2.18 reached it's end of life.

#10 Updated by Giovanni Manghi about 5 years ago

  • Resolution set to no timely feedback
  • Status changed from Feedback to Closed

Also available in: Atom PDF