Ticket #2788 (closed defect: fixed)
Issues related to wildcard expansion in SQL result layer
| Reported by: | rouault | Owned by: | rouault |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.6.1 |
| Component: | OGR_SF | Version: | unspecified |
| Severity: | normal | Keywords: | sql wildcard |
| Cc: |
Description
3 issues related to wildcard expansion :
- Currently, the result of the GetFeatureCount?() in the following snippet is always 1, whatever the number of features in the source layer. This is due to the fact that the source layer has no field (a shapefile without a .dbf, a memory datasource with no field, etc..). In OGRGenSQLResultsLayer::GetFeatureCount?, psSelectInfo->query_mode must be set to SWQM_RECORDSET to return a value different from 1, so in swq_select_parse, we must set the query_mode to SWQM_RECORDSET when select_info->result_columns == 0.
###############################################################################
# Test query on layer without any field
def ogr_sql_20():
mem_ds = ogr.GetDriverByName("Memory").CreateDataSource( "my_ds")
mem_lyr = mem_ds.CreateLayer( "my_layer")
feat = ogr.Feature(mem_lyr.GetLayerDefn() )
feat.SetGeometry(ogr.CreateGeometryFromWkt("POINT(0 1)"))
mem_lyr.CreateFeature( feat )
feat = ogr.Feature(mem_lyr.GetLayerDefn() )
feat.SetGeometry(ogr.CreateGeometryFromWkt("POINT(2 3)"))
mem_lyr.CreateFeature( feat )
sql_lyr = mem_ds.ExecuteSQL("SELECT * from my_layer")
if sql_lyr.GetFeatureCount() != 2:
return 'fail'
mem_ds.ReleaseResultSet(sql_lyr)
mem_ds = None
return 'success'
- Another related issue is that sql_lyr = mem_ds.ExecuteSQL("SELECT *, fid from my_layer") causes a crash when my_layer has no field
- Another related issue is that multiple expansion of wildcard doesn't work, as in sql_lyr = mem_ds.ExecuteSQL("SELECT *, * from my_layer"). Only the first wildcard is expanded.
Change History
Note: See
TracTickets for help on using
tickets.
