Skip to content

Commit 9157173

Browse files
committedNov 18, 2015
Make expression compilation optional, but enabled by default
Remove the previous postgres specific option and replace with an enabled-by-default option which applies to all expression compilation.
1 parent 982490f commit 9157173

10 files changed

+79
-268
lines changed
 

‎src/app/qgsoptions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
575575
cbxSnappingOptionsDocked->setChecked( settings.value( "/qgis/dockSnapping", false ).toBool() );
576576
cbxAddPostgisDC->setChecked( settings.value( "/qgis/addPostgisDC", false ).toBool() );
577577
cbxAddOracleDC->setChecked( settings.value( "/qgis/addOracleDC", false ).toBool() );
578-
cbxCompileExpressions->setChecked( settings.value( "/qgis/postgres/compileExpressions", false ).toBool() );
578+
cbxCompileExpressions->setChecked( settings.value( "/qgis/compileExpressions", true ).toBool() );
579579
cbxCreateRasterLegendIcons->setChecked( settings.value( "/qgis/createRasterLegendIcons", false ).toBool() );
580580
cbxCopyWKTGeomFromTable->setChecked( settings.value( "/qgis/copyGeometryAsWKT", true ).toBool() );
581581
leNullValue->setText( settings.value( "qgis/nullValue", "NULL" ).toString() );
@@ -1102,7 +1102,7 @@ void QgsOptions::saveOptions()
11021102
settings.setValue( "/qgis/dockSnapping", cbxSnappingOptionsDocked->isChecked() );
11031103
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );
11041104
settings.setValue( "/qgis/addOracleDC", cbxAddOracleDC->isChecked() );
1105-
settings.setValue( "/qgis/postgres/compileExpressions", cbxCompileExpressions->isChecked() );
1105+
settings.setValue( "/qgis/compileExpressions", cbxCompileExpressions->isChecked() );
11061106
settings.setValue( "/qgis/defaultLegendGraphicResolution", mLegendGraphicResolutionSpinBox->value() );
11071107
bool createRasterLegendIcons = settings.value( "/qgis/createRasterLegendIcons", false ).toBool();
11081108
settings.setValue( "/qgis/createRasterLegendIcons", cbxCreateRasterLegendIcons->isChecked() );

‎src/providers/ogr/qgsogrfeatureiterator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource* source, bool
8484
OGR_L_SetSpatialFilter( ogrLayer, 0 );
8585
}
8686

87-
if ( request.filterType() == QgsFeatureRequest::FilterExpression )
87+
if ( request.filterType() == QgsFeatureRequest::FilterExpression
88+
&& QSettings().value( "/qgis/compileExpressions", true ).toBool() )
8889
{
8990
QgsOgrExpressionCompiler compiler = QgsOgrExpressionCompiler( source );
9091

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,8 @@ QString QgsOgrUtils::quotedValue( const QVariant& value )
25772577
return value.toString();
25782578

25792579
case QVariant::Bool:
2580-
return value.toBool() ? "TRUE" : "FALSE";
2580+
//OGR does not support boolean literals
2581+
return value.toBool() ? "1" : "0";
25812582

25822583
default:
25832584
case QVariant::String:

‎src/providers/postgres/qgspostgresfeatureiterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ QgsPostgresFeatureIterator::QgsPostgresFeatureIterator( QgsPostgresFeatureSource
7777
whereClause = QgsPostgresUtils::andWhereClauses( whereClause, fidsWhereClause );
7878
}
7979
else if ( request.filterType() == QgsFeatureRequest::FilterExpression
80-
&& QSettings().value( "/qgis/postgres/compileExpressions", false ).toBool() )
80+
&& QSettings().value( "/qgis/compileExpressions", true ).toBool() )
8181
{
8282
QgsPostgresExpressionCompiler compiler = QgsPostgresExpressionCompiler( source );
8383

‎src/providers/spatialite/qgsspatialitefeatureiterator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222
#include "qgslogger.h"
2323
#include "qgsmessagelog.h"
24-
25-
24+
#include <QSettings>
2625

2726
QgsSpatiaLiteFeatureIterator::QgsSpatiaLiteFeatureIterator( QgsSpatiaLiteFeatureSource* source, bool ownSource, const QgsFeatureRequest& request )
2827
: QgsAbstractFeatureIteratorFromSource<QgsSpatiaLiteFeatureSource>( source, ownSource, request )
@@ -64,7 +63,8 @@ QgsSpatiaLiteFeatureIterator::QgsSpatiaLiteFeatureIterator( QgsSpatiaLiteFeature
6463
whereClauses.append( whereClause );
6564
}
6665
}
67-
else if ( request.filterType() == QgsFeatureRequest::FilterExpression )
66+
else if ( request.filterType() == QgsFeatureRequest::FilterExpression
67+
&& QSettings().value( "/qgis/compileExpressions", true ).toBool() )
6868
{
6969
QgsSpatiaLiteExpressionCompiler compiler = QgsSpatiaLiteExpressionCompiler( source );
7070

‎src/ui/qgsoptionsbase.ui

Lines changed: 50 additions & 257 deletions
Large diffs are not rendered by default.

‎tests/src/python/providertestbase.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def runGetFeatureTests(self, provider):
6565
self.assert_query(provider, '"name" ~ \'[OP]ra[gne]+\'', [1])
6666
self.assert_query(provider, '"name"="name2"', [2, 4]) # mix of matched and non-matched case sensitive names
6767
self.assert_query(provider, 'true', [1, 2, 3, 4, 5])
68+
self.assert_query(provider, 'false', [])
69+
6870
#Three value logic
6971
self.assert_query(provider, 'false and false', [])
7072
self.assert_query(provider, 'false and true', [])
@@ -87,6 +89,7 @@ def runGetFeatureTests(self, provider):
8789
self.assert_query(provider, 'not true', [])
8890
self.assert_query(provider, 'not false', [1, 2, 3, 4, 5])
8991
self.assert_query(provider, 'not null', [])
92+
9093
#not
9194
self.assert_query(provider, 'not name = \'Apple\'', [1, 3, 4])
9295
self.assert_query(provider, 'not name IS NULL', [1, 2, 3, 4])

‎tests/src/python/test_provider_postgres.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def tearDownClass(cls):
4848
"""Run after all tests"""
4949

5050
def enableCompiler(self):
51-
QSettings().setValue(u'/qgis/postgres/compileExpressions', True)
51+
QSettings().setValue(u'/qgis/compileExpressions', True)
5252

5353
def disableCompiler(self):
54-
QSettings().setValue(u'/qgis/postgres/compileExpressions', False)
54+
QSettings().setValue(u'/qgis/compileExpressions', False)
5555

5656
# HERE GO THE PROVIDER SPECIFIC TESTS
5757
def testDefaultValue(self):

‎tests/src/python/test_provider_shapefile.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
TEST_DATA_DIR = unitTestDataPath()
3131

3232

33-
class TestPyQgsPostgresProvider(TestCase, ProviderTestCase):
33+
class TestPyQgsShapefileProvider(TestCase, ProviderTestCase):
3434

3535
@classmethod
3636
def setUpClass(cls):
@@ -55,6 +55,12 @@ def tearDownClass(cls):
5555
shutil.rmtree(cls.basetestpath, True)
5656
shutil.rmtree(cls.repackfilepath, True)
5757

58+
def enableCompiler(self):
59+
QSettings().setValue(u'/qgis/compileExpressions', True)
60+
61+
def disableCompiler(self):
62+
QSettings().setValue(u'/qgis/compileExpressions', False)
63+
5864
def testRepack(self):
5965
vl = QgsVectorLayer(u'{}|layerid=0'.format(self.repackfile), u'test', u'ogr')
6066

‎tests/src/python/test_provider_spatialite.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
unittest
2626
)
2727
from providertestbase import ProviderTestCase
28+
from PyQt4.QtCore import QSettings
2829

2930
try:
3031
from pyspatialite import dbapi2 as sqlite3
@@ -122,6 +123,12 @@ def tearDown(self):
122123
"""Run after each test."""
123124
pass
124125

126+
def enableCompiler(self):
127+
QSettings().setValue(u'/qgis/compileExpressions', True)
128+
129+
def disableCompiler(self):
130+
QSettings().setValue(u'/qgis/compileExpressions', False)
131+
125132
def test_SplitFeature(self):
126133
"""Create spatialite database"""
127134
layer = QgsVectorLayer("dbname=%s table=test_pg (geometry)" % self.dbname, "test_pg", "spatialite")

0 commit comments

Comments
 (0)
Please sign in to comment.