Compile some string functions

This commit is contained in:
Nyall Dawson 2017-01-03 14:34:38 +10:00
parent 30f498f006
commit 57917ab118
4 changed files with 22 additions and 2 deletions

View File

@ -92,7 +92,12 @@ static const QMap<QString, QString>& functionNamesSqlFunctionsMap()
fnNames = fnNames =
{ {
{ "abs", "abs" }, { "abs", "abs" },
{ "round", "round" } { "char", "char" },
{ "coalesce", "coalesce" },
{ "lower", "lower" },
{ "round", "round" },
{ "trim", "trim" },
{ "upper", "upper" },
}; };
} }
return fnNames; return fnNames;

View File

@ -102,7 +102,12 @@ static const QMap<QString, QString>& functionNamesSqlFunctionsMap()
{ "union", "ST_Union" }, { "union", "ST_Union" },
#endif #endif
{ "geom_from_wkt", "ST_GeomFromText" }, { "geom_from_wkt", "ST_GeomFromText" },
{ "geom_from_gml", "ST_GeomFromGML" } { "geom_from_gml", "ST_GeomFromGML" },
{ "char", "chr" },
{ "coalesce", "coalesce" },
{ "lower", "lower" },
{ "trim", "trim" },
{ "upper", "upper" },
}; };
} }
return fnNames; return fnNames;

View File

@ -252,6 +252,11 @@ class ProviderTestCase(object):
self.assert_query(provider, 'floor(cnt / 66.67) <= 2', [1, 2, 5]) self.assert_query(provider, 'floor(cnt / 66.67) <= 2', [1, 2, 5])
self.assert_query(provider, 'ceil(cnt / 66.67) <= 2', [1, 5]) self.assert_query(provider, 'ceil(cnt / 66.67) <= 2', [1, 5])
self.assert_query(provider, 'pk < pi() / 2', [1]) self.assert_query(provider, 'pk < pi() / 2', [1])
self.assert_query(provider, 'pk = char(51)', [3])
self.assert_query(provider, 'pk = coalesce(NULL,3,4)', [3])
self.assert_query(provider, 'lower(name) = \'apple\'', [2])
self.assert_query(provider, 'upper(name) = \'APPLE\'', [2])
self.assert_query(provider, 'name = trim(\' Apple \')', [2])
# geometry # geometry
# azimuth and touches tests are deactivated because they do not pass for WFS provider # azimuth and touches tests are deactivated because they do not pass for WFS provider

View File

@ -155,6 +155,11 @@ class TestPyQgsShapefileProvider(unittest.TestCase, ProviderTestCase):
'floor(cnt / 66.67) <= 2', 'floor(cnt / 66.67) <= 2',
'ceil(cnt / 66.67) <= 2', 'ceil(cnt / 66.67) <= 2',
'pk < pi() / 2', 'pk < pi() / 2',
'pk = char(51)',
'pk = coalesce(NULL,3,4)',
'lower(name) = \'apple\'',
'upper(name) = \'APPLE\'',
'name = trim(\' Apple \')',
'x($geometry) < -70', 'x($geometry) < -70',
'y($geometry) > 70', 'y($geometry) > 70',
'xmin($geometry) < -70', 'xmin($geometry) < -70',