Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix build on trusty & xenial
  • Loading branch information
jef-n committed Sep 23, 2017
1 parent 381c8b6 commit 75afe3f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -1174,7 +1174,7 @@ const QgsFields & QgsOgrProvider::fields() const
}


//TODO - add sanity check for shape file layers, to include cheking to
//TODO - add sanity check for shape file layers, to include checking to
// see if the .shp, .dbf, .shx files are all present and the layer
// actually has features
bool QgsOgrProvider::isValid()
Expand Down Expand Up @@ -3449,7 +3449,7 @@ OGRLayerH QgsOgrProviderUtils::setSubsetString( OGRLayerH layer, OGRDataSourceH
QByteArray sql = encoding->fromUnicode( subsetString );

QgsDebugMsg( QString( "SQL: %1" ).arg( encoding->toUnicode( sql ) ) );
subsetLayer = GDALDatasetExecuteSQL( ds, sql.constData(), nullptr, nullptr );
subsetLayer = OGR_DS_ExecuteSQL( ds, sql.constData(), nullptr, nullptr );
}
else
{
Expand All @@ -3468,22 +3468,22 @@ OGRLayerH QgsOgrProviderUtils::setSubsetString( OGRLayerH layer, OGRDataSourceH

QByteArray sql = sqlPart1 + ", " + fidColumn + " as orig_ogc_fid" + sqlPart3;
QgsDebugMsg( QString( "SQL: %1" ).arg( encoding->toUnicode( sql ) ) );
subsetLayer = GDALDatasetExecuteSQL( ds, sql.constData(), nullptr, nullptr );
subsetLayer = OGR_DS_ExecuteSQL( ds, sql.constData(), nullptr, nullptr );

// See https://lists.osgeo.org/pipermail/qgis-developer/2017-September/049802.html
// If execute SQL fails because it did not find the fidColumn, retry with hardcoded FID
if ( !subsetLayer )
{
QByteArray sql = sqlPart1 + ", " + "FID as orig_ogc_fid" + sqlPart3;
QgsDebugMsg( QString( "SQL: %1" ).arg( encoding->toUnicode( sql ) ) );
subsetLayer = GDALDatasetExecuteSQL( ds, sql.constData(), nullptr, nullptr );
subsetLayer = OGR_DS_ExecuteSQL( ds, sql.constData(), nullptr, nullptr );
}
// If that also fails, just continue without the orig_ogc_fid
if ( !subsetLayer )
{
QByteArray sql = sqlPart1 + sqlPart3;
QgsDebugMsg( QString( "SQL: %1" ).arg( encoding->toUnicode( sql ) ) );
subsetLayer = GDALDatasetExecuteSQL( ds, sql.constData(), nullptr, nullptr );
subsetLayer = OGR_DS_ExecuteSQL( ds, sql.constData(), nullptr, nullptr );
origFidAddAttempted = false;
}
}
Expand Down

0 comments on commit 75afe3f

Please sign in to comment.