Skip to content

Commit

Permalink
Unfinished attempt to fix #51934
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso authored and github-actions[bot] committed Mar 10, 2023
1 parent 56d1e71 commit bc48595
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/providers/ogr/qgsogrfeatureiterator.cpp
Expand Up @@ -287,7 +287,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
// when the logger was disabled.
// There is currently no API to connect the change of state of the
// logger to the data provider.
if ( QgsApplication::databaseQueryLog()->enabled() )
if ( QgsApplication::databaseQueryLog()->enabled() && mConn )
{
GDALDatasetSetQueryLoggerFunc( mConn->ds, [ ]( const char *pszSQL, const char *pszError, int64_t lNumRecords, int64_t lExecutionTimeMilliseconds, void *pQueryLoggerArg )
{
Expand Down
17 changes: 12 additions & 5 deletions src/core/qgstransaction.cpp
Expand Up @@ -72,14 +72,21 @@ QString QgsTransaction::connectionString() const
}

// For the needs of the OGR provider with GeoPackage datasources, remove
// any reference to layers in the connection string
QString QgsTransaction::removeLayerIdOrName( const QString &str )
// any reference to layers and filters in the connection string
QString QgsTransaction::cleanupConnectionString( const QString &str )
{
QString res( str );

for ( int i = 0; i < 2; i++ )
static const QStringList toRemove
{
const int pos = res.indexOf( i == 0 ? QLatin1String( "|layername=" ) : QLatin1String( "|layerid=" ) );
{ QStringLiteral( "|layername=" )},
{ QStringLiteral( "|layerid=" )},
{ QStringLiteral( "|subset=" )},
};

for ( const auto &strToRm : std::as_const( toRemove ) )
{
const int pos = res.indexOf( strToRm );
if ( pos >= 0 )
{
const int end = res.indexOf( '|', pos + 1 );
Expand All @@ -105,7 +112,7 @@ QString QgsTransaction::connectionString( const QString &layerUri )
// reference to layers from it.
if ( connString.isEmpty() )
{
connString = removeLayerIdOrName( layerUri );
connString = cleanupConnectionString( layerUri );
}
return connString;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgstransaction.h
Expand Up @@ -201,7 +201,7 @@ class CORE_EXPORT QgsTransaction : public QObject SIP_ABSTRACT

void setLayerTransactionIds( QgsTransaction *transaction );

static QString removeLayerIdOrName( const QString &str );
static QString cleanupConnectionString( const QString &str );

virtual bool beginTransaction( QString &error, int statementTimeout ) = 0;
virtual bool commitTransaction( QString &error ) = 0;
Expand Down

0 comments on commit bc48595

Please sign in to comment.