Opened 13 years ago

Closed 13 years ago

#4263 closed defect (fixed)

FileGDB SQL errors for attribute names containing underscores

Reported by: peifer Owned by: warmerdam
Priority: normal Milestone: 1.9.0
Component: OGR_SF Version: svn-trunk
Severity: normal Keywords: FileGDB
Cc:

Description

For String type attributes, the query: -where "code_06 = '333'" works fine, but the corresponding -sql "..." query doesn't see (0). No error message is given :-(

For Real type attributes: a query on AreaHa works fine, but not the same query on Area_Ha, see (1). At least some errors are given. When counting on Real type attributes, I am getting more errors, see (2)

test.gdb is attached. I created it from a larger FileGDB by duplicating attributes which had underscores in their name: {ogr2ogr -f filegdb test.gdb clc2006_v15.gdb -sql "select *, code_06 as code06, Area_Ha as AreaHa, Shape_Length as ShapeLength, Shape_Area as ShapeArea from clc06 where id like '%123123%'"

(0)

$ ogrinfo -al -q -geom=no test.gdb -where "code_06 = '333'"

Layer name: clc06
OGRFeature(clc06):1
  code_06 (String) = 333
  ID (String) = EU-123123
  REMARK (String) = (null)
  Area_Ha (Real) = 1455.82795731355
  Shape_Length (Real) = 47195.6065635209
  Shape_Area (Real) = 14558279.5731355
  code06 (String) = 333
  AreaHa (Real) = 1455.82795731355
  ShapeLength (Real) = 47195.6065635209
  ShapeArea (Real) = 14558279.5731355

$ ogrinfo -q -geom=no test.gdb -sql "select * from clc06 where code_06 = '333'"

Layer name: clc06

$ ogrinfo -q -geom=no test.gdb -sql "select * from clc06 where code06 = '333'"

Layer name: clc06
OGRFeature(clc06):1
  code_06 (String) = 333
  ID (String) = EU-123123
  REMARK (String) = (null)
  Area_Ha (Real) = 1455.82795731355
  Shape_Length (Real) = 47195.6065635209
  Shape_Area (Real) = 14558279.5731355
  code06 (String) = 333
  AreaHa (Real) = 1455.82795731355
  ShapeLength (Real) = 47195.6065635209
  ShapeArea (Real) = 14558279.5731355

(1)

$ ogrinfo -q -geom=no test.gdb -sql "select *  from clc06 where AreaHa > 1000"

Layer name: clc06
OGRFeature(clc06):1
  code_06 (String) = 333
  ID (String) = EU-123123
  REMARK (String) = (null)
  Area_Ha (Real) = 1455.82795731355
  Shape_Length (Real) = 47195.6065635209
  Shape_Area (Real) = 14558279.5731355
  code06 (String) = 333
  AreaHa (Real) = 1455.82795731355
  ShapeLength (Real) = 47195.6065635209
  ShapeArea (Real) = 14558279.5731355

OGRFeature(clc06):3
  code_06 (String) = 211
  ID (String) = EU-1231230
  REMARK (String) = (null)
  Area_Ha (Real) = 4632.84552213033
  Shape_Length (Real) = 97023.8237965733
  Shape_Area (Real) = 46328455.2213033
  code06 (String) = 211
  AreaHa (Real) = 4632.84552213033
  ShapeLength (Real) = 97023.8237965733
  ShapeArea (Real) = 46328455.2213033

$ ogrinfo -q -geom=no test.gdb -sql "select *  from clc06 where Area_Ha > 1000"
ERROR 1: Error: Failed Searching (An invalid SQL statement was used.)

Layer name: clc06
ERROR 1: Error: Failed fetching features (Unexpected operation.)

(2)

$ ogrinfo -q -geom=no test.gdb -sql "select count(*)  from clc06 where AreaHa > 1000"

Layer name: clc06
OGRFeature(clc06):0
  COUNT_* (Integer) = 2

$ ogrinfo -q -geom=no test.gdb -sql "select count(*)  from clc06 where Area_Ha > 1000"

Layer name: clc06
ERROR 1: Error: Failed Searching (An invalid SQL statement was used.)
ERROR 1: Error: Failed Searching (An invalid SQL statement was used.)
ERROR 1: Error: Failed fetching features (Unexpected operation.)
ERROR 1: Error: Failed Searching (An invalid SQL statement was used.)
OGRFeature(clc06):0
  COUNT_* (Integer) = 0

Attachments (1)

testfile.zip (37.3 KB ) - added by peifer 13 years ago.
test.gdb

Download all attachments as: .zip

Change History (2)

by peifer, 13 years ago

Attachment: testfile.zip added

test.gdb

comment:1 by Even Rouault, 13 years ago

Milestone: 1.9.0
Resolution: fixed
Status: newclosed

r23123 /trunk/gdal/ogr/ (ogrsf_frmts/generic/ogrdatasource.cpp swq_expr_node.cpp): Avoid quoting column names that contain '_' char when rebuilding the where clause; Use double-quote char for quoting column names for FileGDB driver (#4263)

Note: See TracTickets for help on using tickets.