Skip to content

Commit

Permalink
Nicer strings for OGR sql dialects
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 18, 2024
1 parent a7d17fe commit 7af7cbd
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions src/core/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,20 @@ QString QgsOgrProvider::subsetStringDialect() const
{
const QStringList dialects = QString( pszSqlDialects ).split( ' ' );
// first dialect is default, which is what QGIS uses
return !dialects.empty() ? dialects.at( 0 ) : QString();
const QString defaultDialect = !dialects.isEmpty() ? dialects.at( 0 ) : QString();
if ( defaultDialect == QLatin1String( "NATIVE" ) )
{
return tr( "%1 query" ).arg( GDALGetDriverLongName( mOgrLayer->driver() ) );
}
else if ( defaultDialect == QLatin1String( "OGRSQL" ) )
{
return tr( "OGR SQL query" );
}
else if ( defaultDialect == QLatin1String( "SQLITE" ) )
{
return tr( "SQLite query" );
}
return defaultDialect;
}
}
#endif
Expand All @@ -582,19 +595,29 @@ QString QgsOgrProvider::subsetStringDialect() const

QString QgsOgrProvider::subsetStringHelpUrl() const
{
const QString dialect = subsetStringDialect();
if ( dialect == QLatin1String( "NATIVE" ) && mOgrLayer )
{
return QgsGdalUtils::gdalDocumentationUrlForDriver( mOgrLayer->driver() );
}
else if ( dialect == "OGRSQL" )
{
return QStringLiteral( "https://gdal.org/user/ogr_sql_dialect.html" );
}
else if ( dialect == "SQLITE" )
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,6,0)
if ( mOgrLayer )
{
return QStringLiteral( "https://gdal.org/user/sql_sqlite_dialect.html" );
if ( const char *pszSqlDialects = GDALGetMetadataItem( mOgrLayer->driver(), GDAL_DMD_SUPPORTED_SQL_DIALECTS, nullptr ) )
{
const QStringList dialects = QString( pszSqlDialects ).split( ' ' );
// first dialect is default, which is what QGIS uses
const QString defaultDialect = !dialects.isEmpty() ? dialects.at( 0 ) : QString();
if ( defaultDialect == QLatin1String( "NATIVE" ) )
{
return QgsGdalUtils::gdalDocumentationUrlForDriver( mOgrLayer->driver() );
}
else if ( defaultDialect == QLatin1String( "OGRSQL" ) )
{
return QStringLiteral( "https://gdal.org/user/ogr_sql_dialect.html" );
}
else if ( defaultDialect == QLatin1String( "SQLITE" ) )
{
return QStringLiteral( "https://gdal.org/user/sql_sqlite_dialect.html" );
}
}
}
#endif
return QString();
}

Expand Down

0 comments on commit 7af7cbd

Please sign in to comment.