Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#6963 closed defect (invalid)

OGR SQL limits table name character set

Reported by: theroggy Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:

Description (last modified by theroggy)

When executing an sql statement on a shapefile that has '-' in the filename you get an error. It seems the sql parser doesn't support this.

Can be reproduced like this:

ogrinfo Perc_2017-06-11_ANTW.shp -sql "select * from Perc_2017-06-11_ANTW"
INFO: Open of `Perc_2017-06-11_ANTW.shp' using driver `ESRI Shapefile' successful.
ERROR 1: SQL Expression Parsing Error: syntax error, unexpected '-', expecting end of string. 
Occurred around : select * from Perc_2017-06-11_ANTW

Change History (3)

comment:1 Changed 2 years ago by theroggy

Description: modified (diff)

comment:2 Changed 2 years ago by Even Rouault

Resolution: invalid
Status: newclosed

You need to double quote columns or tables identifiers that have special characters like '-' (and as you use shell commands escape them with \

ogrinfo Perc_2017-06-11_ANTW.shp -sql "select * from \"Perc_2017-06-11_ANTW\""

This is conformant with the SQL92 standard

comment:3 Changed 2 years ago by theroggy

Ok, thanks!

Note: See TracTickets for help on using tickets.