Skip to content

Commit bbc3055

Browse files
committed
Better boolean support detection for GDAL >= 2.3
1 parent c15ef22 commit bbc3055

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/providers/ogr/qgsogrprovider.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -466,20 +466,32 @@ QgsOgrProvider::QgsOgrProvider( QString const &uri )
466466
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), QStringLiteral( "datetime" ), QVariant::DateTime );
467467
}
468468

469+
bool supportsBoolean = false;
470+
471+
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,3,0)
472+
const char *pszDataTypes = GDALGetMetadataItem( mOgrOrigLayer->driver(), GDAL_DMD_CREATIONFIELDDATASUBTYPES, nullptr );
473+
if ( pszDataTypes && strstr( pszDataTypes, "Boolean" ) )
474+
supportsBoolean = true;
475+
#else
469476
if ( mGDALDriverName == QLatin1String( "GeoJSON" ) ||
470477
mGDALDriverName == QLatin1String( "GML" ) ||
471478
mGDALDriverName == QLatin1String( "CSV" ) ||
472479
mGDALDriverName == QLatin1String( "PostgreSQL" ) ||
473480
mGDALDriverName == QLatin1String( "PGDump" ) ||
474481
mGDALDriverName == QLatin1String( "SQLite" ) ||
475482
mGDALDriverName == QLatin1String( "GPKG" ) )
483+
{
484+
supportsBoolean = true;
485+
}
486+
#endif
487+
488+
if ( supportsBoolean )
476489
{
477490
// boolean data type
478491
nativeTypes
479492
<< QgsVectorDataProvider::NativeType( tr( "Boolean" ), QStringLiteral( "bool" ), QVariant::Bool, -1, -1, -1, -1 );
480493
}
481494

482-
483495
setNativeTypes( nativeTypes );
484496

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

0 commit comments

Comments
 (0)