Bug report #6235
Problem with primary keys in MSSQL provider
|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|
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