Skip to content

Commit dbb0919

Browse files
committed
Handle order by parsing failures in postgres provider
1 parent f241059 commit dbb0919

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/providers/postgres/qgspostgresfeatureiterator.cpp

+21-1
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,28 @@ QgsPostgresFeatureIterator::QgsPostgresFeatureIterator( QgsPostgresFeatureSource
153153
if ( !success && useFallbackWhereClause )
154154
{
155155
//try with the fallback where clause, eg for cases when using compiled expression failed to prepare
156-
mExpressionCompiled = false;
157156
success = declareCursor( fallbackWhereClause, -1, false, orderByParts.join( "," ) );
157+
if ( success )
158+
mExpressionCompiled = false;
159+
}
160+
161+
if ( !success && !orderByParts.isEmpty() )
162+
{
163+
//try with no order by clause
164+
success = declareCursor( whereClause, -1, false );
165+
if ( success )
166+
mOrderByCompiled = false;
167+
}
168+
169+
if ( !success && useFallbackWhereClause && !orderByParts.isEmpty() )
170+
{
171+
//try with no expression compilation AND no order by clause
172+
success = declareCursor( fallbackWhereClause, -1, false );
173+
if ( success )
174+
{
175+
mExpressionCompiled = false;
176+
mOrderByCompiled = false;
177+
}
158178
}
159179

160180
if ( !success )

0 commit comments

Comments
 (0)