Skip to content

Commit 491397c

Browse files
committed
OGR Spatialite: do not be case sensitive if DATA is a SELECT ... FROM table_name
1 parent 45037eb commit 491397c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mapogr.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ static void msOGRFileOpenSpatialite( layerObj *layer,
13761376

13771377
char* pszRequest = NULL;
13781378
pszRequest = msStringConcatenate(pszRequest,
1379-
"SELECT * FROM sqlite_master WHERE type = 'table' AND name = lower('");
1379+
"SELECT name FROM sqlite_master WHERE type = 'table' AND name = lower('");
13801380
pszRequest = msStringConcatenate(pszRequest, psInfo->pszMainTableName);
13811381
pszRequest = msStringConcatenate(pszRequest, "')");
13821382
OGRLayerH hLayer = OGR_DS_ExecuteSQL( psInfo->hDS, pszRequest, NULL, NULL );
@@ -1387,7 +1387,13 @@ static void msOGRFileOpenSpatialite( layerObj *layer,
13871387
OGRFeatureH hFeature = OGR_L_GetNextFeature(hLayer);
13881388
psInfo->bIsOKForSQLCompose = (hFeature != NULL);
13891389
if( hFeature )
1390+
{
1391+
msFree(psInfo->pszMainTableName);
1392+
msFree(psInfo->pszSpatialFilterTableName);
1393+
psInfo->pszMainTableName = msStrdup( OGR_F_GetFieldAsString( hFeature, 0) );
1394+
psInfo->pszSpatialFilterTableName = msStrdup( psInfo->pszMainTableName );
13901395
OGR_F_Destroy(hFeature);
1396+
}
13911397
OGR_DS_ReleaseResultSet( psInfo->hDS, hLayer );
13921398
}
13931399
if( psInfo->bIsOKForSQLCompose )
@@ -1510,6 +1516,7 @@ static void msOGRFileOpenSpatialite( layerObj *layer,
15101516
pszRequest = msStringConcatenate(pszRequest, "'");
15111517

15121518
psInfo->bHasSpatialIndex = false;
1519+
//msDebug("msOGRFileOpen(): %s", pszRequest);
15131520

15141521
OGRLayerH hLayer = OGR_DS_ExecuteSQL( psInfo->hDS, pszRequest, NULL, NULL );
15151522
if( hLayer )

0 commit comments

Comments
 (0)