Bug report #6235

Problem with primary keys in MSSQL provider

Added by Alexander Bruy about 7 years ago. Updated about 7 years ago.

Status:Closed
Priority:Normal
Assignee:Tamas Szekeres
Category:Data Provider/MSSQL
Affected QGIS version:master Regression?:No
Operating System:all Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:fixed
Crashes QGIS or corrupts data:No Copied to github as #:15544

Description

Table has bigint primary key. When loading it to QGIS all field values are displayed as "ERROR", but identify tool works fine. Also table reports correct number of features and field types detected correctly. Seems this related with possible integer overflow in nextFeature() method (line 523).

From Qt docs
Warning: If the value is convertible to a LongLong but is too large to be represented in an int, the resulting arithmetic overflow will not be reflected in ok. A simple workaround is to use QString::toInt(). Fixing this bug has been postponed to Qt 5 in order to avoid breaking existing code.

Here is simple patch that should fix it

fix_pk_issue_mssql.patch Magnifier (481 Bytes) Alexander Bruy, 2012-08-21 09:08 AM

Associated revisions

History

#1 Updated by Alexander Bruy about 7 years ago

  • Category changed from Data Provider to Data Provider/MSSQL

#2 Updated by Evgeniy Nikulin about 7 years ago

I tried the patch on qgis trunk (Fedora 17 x86_64) and MS SQL Server 2008 - it works. My tables with bigint keys well displayed in the table of attributes.

#3 Updated by Alexander Bruy about 7 years ago

  • Status changed from Open to Closed

#4 Updated by Alexander Bruy about 7 years ago

  • Resolution set to fixed

Also available in: Atom PDF