Skip to content
Permalink
Browse files

Better boolean support detection for GDAL >= 2.3

  • Loading branch information
nyalldawson committed Dec 12, 2017
1 parent c15ef22 commit bbc3055b07d5f07a59d8e767fa701d764b399ec8
Showing with 13 additions and 1 deletion.
  1. +13 −1 src/providers/ogr/qgsogrprovider.cpp
@@ -466,20 +466,32 @@ QgsOgrProvider::QgsOgrProvider( QString const &uri )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), QStringLiteral( "datetime" ), QVariant::DateTime );
}

bool supportsBoolean = false;

#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,3,0)
const char *pszDataTypes = GDALGetMetadataItem( mOgrOrigLayer->driver(), GDAL_DMD_CREATIONFIELDDATASUBTYPES, nullptr );
if ( pszDataTypes && strstr( pszDataTypes, "Boolean" ) )
supportsBoolean = true;
#else
if ( mGDALDriverName == QLatin1String( "GeoJSON" ) ||
mGDALDriverName == QLatin1String( "GML" ) ||
mGDALDriverName == QLatin1String( "CSV" ) ||
mGDALDriverName == QLatin1String( "PostgreSQL" ) ||
mGDALDriverName == QLatin1String( "PGDump" ) ||
mGDALDriverName == QLatin1String( "SQLite" ) ||
mGDALDriverName == QLatin1String( "GPKG" ) )
{
supportsBoolean = true;
}
#endif

if ( supportsBoolean )
{
// boolean data type
nativeTypes
<< QgsVectorDataProvider::NativeType( tr( "Boolean" ), QStringLiteral( "bool" ), QVariant::Bool, -1, -1, -1, -1 );
}


setNativeTypes( nativeTypes );

QgsOgrConnPool::instance()->ref( QgsOgrProviderUtils::connectionPoolId( dataSourceUri( true ) ) );

0 comments on commit bbc3055

Please sign in to comment.
You can’t perform that action at this time.