I've tried adding a vector from Mysql table (Mysql 5.1, MyISAM) to QGIS 2.6. All columns are visible except Primary key column(s).
Could anyone confirm this behaviour? Could we consider it a bug?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
I believe that GDAL is taking your primary key column and uses it as a FID which is the internal Feature ID. That is not meant to be published as a normal attribute. See the following example. The table in the Spatialite has a column OGC_FID which is selected to be used as FID and it does not appear in the attributes of the feature. The value of the OGC_FID field is used in
ogrinfo OSM.sqlite points INFO: Open of `OSM.sqlite' using driver `SQLite' successful. Layer name: points Geometry: Point Feature Count: 314281 Extent: (19.065536, 59.457619) - (31.464966, 70.089821) Layer SRS WKT: GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]] FID Column = OGC_FID <= this line shows where the FID is taken Geometry Column = GEOMETRY osm_id: String (0.0) name: String (0.0) barrier: String (0.0) highway: String (0.0) ref: String (0.0) address: String (0.0) is_in: String (0.0) place: String (0.0) man_made: String (0.0) other_tags: String (0.0) OGRFeature(points):1 <= No OGC_FID included in the attributes osm_id (String) = 115899 name (String) = (null) barrier (String) = (null) highway (String) = traffic_signals ref (String) = (null) address (String) = (null) is_in (String) = (null) place (String) = (null) man_made (String) = (null) other_tags (String) = (null) POINT (25.7409545 66.49637)
There are workarounds. You must select the fid as a normal attribute and you can probably do it either in
ogrinfo OSM.sqlite -sql "select ogc_fid as exposed_fid, name, geometry from points" INFO: Open of OSM.sqlite using driver SQLite successful. Layer name: SELECT Geometry: Unknown (any) Feature Count: 314281 OGRFeature(SELECT):0 exposed_fid (Integer) = 1 <= OGC_FID now listed as a normal attribute name (String) = (null) POINT (25.7409545 66.49637)