Opened 18 years ago

Closed 8 years ago

#1093 closed defect (wontfix)

ogr sql can't see field named id in mysql database

Reported by: jef.mony@… Owned by: hobu
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description (last modified by Jukka Rahkonen)

ogrinfo -ro /root/sa_lo_bis.shp -sql "select * from
'MYSQL:lyon,user=root,port=3306'.lones"

this command retrieves all fields of the lones table, but this table has a field
named id, the primary key, wich is not listed.
I created a similar field named id_web wich is retrieves.
I tried with another table with filed named id, and the problem was the same.

Change History (4)

comment:1 by warmerdam, 18 years ago

Howard, 

I assume the problem is that id is being treated as the FID and stripped from
the conventional fields for the layer.

I think we may need to include the FID column in the regular attributes (as well
as using it for FID) unless it is named OGC_FID (or OGR_FID?), whatever our
OGR generated FID column is called. 

Does that make sense.

comment:2 by kyngchaos@…, 18 years ago

>I think we may need to include the FID column in the regular attributes

Will this make it into the 1.3.2 release?  I'm trying to get a shapefile to mysql join to work, but it's not 
seeing the mysql id field because it thinks it's the FID.  I've tried renaming the field a variety of ways, but it 
still decides it's an FID (maybe due to primary key on an integer?).  I'm using the 2006/4/10 CVS 
snapshot.

comment:3 by Even Rouault, 9 years ago

Priority: highnormal

All those tickets have more than one year and nobody has acted on it, so the priority is not so high

comment:4 by Jukka Rahkonen, 8 years ago

Description: modified (diff)
Resolution: wontfix
Status: newclosed

I am closing this ticket because it is not specific to MySQL. FIDs are not treated like ordinary fields but how, it depends on drivers. A simple workaround in this case is to use "SELECT id as id, * from...".

Maybe ogrinfo and ogr2ogr could have a general "-expose_fid" option that would copy the FID field into a normal attribute. If FIDs are exposed then they can also be edited which is usually a bad idea but perhaps GDAL users know what they are doing.

Note: See TracTickets for help on using tickets.