diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index 8974dc379..c6a95d3e0 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -63,6 +63,11 @@ struct both_arithmetic : std::integral_constant static auto apply(T const& lhs, T const& rhs) -> decltype(lhs == rhs) @@ -73,6 +78,15 @@ struct equals struct not_equal { + // back compatibility shim to equate empty string with null for != test + // https://github.com/mapnik/mapnik/issues/1859 + // TODO - consider removing entire specialization at Mapnik 3.1.x + static bool apply(value_null, value_unicode_string const& rhs) + { + if (rhs.isEmpty()) return false; + return true; + } + template static auto apply(T const& lhs, T const& rhs) ->decltype(lhs != rhs) @@ -83,6 +97,11 @@ struct not_equal struct greater_than { + static bool apply(value_null, value_unicode_string const& rhs) + { + return false; + } + template static auto apply(T const& lhs, T const& rhs) ->decltype(lhs > rhs) @@ -93,6 +112,11 @@ struct greater_than struct greater_or_equal { + static bool apply(value_null, value_unicode_string const& rhs) + { + return false; + } + template static auto apply(T const& lhs, T const& rhs) ->decltype(lhs >= rhs) @@ -103,6 +127,11 @@ struct greater_or_equal struct less_than { + static bool apply(value_null, value_unicode_string const& rhs) + { + return false; + } + template static auto apply(T const& lhs, T const& rhs) ->decltype(lhs < rhs) @@ -113,6 +142,11 @@ struct less_than struct less_or_equal { + static bool apply(value_null, value_unicode_string const& rhs) + { + return false; + } + template static auto apply(T const& lhs, T const& rhs) ->decltype(lhs <= rhs) @@ -130,9 +164,20 @@ struct comparison bool operator() (value_unicode_string const& lhs, value_unicode_string const& rhs) const { - return Op::apply(lhs, rhs) ? true: false; + return Op::apply(lhs, rhs) ? true : false; } + ////////////////////////////////////////////////////////////////////////// + // special case for unicode_string and value_null + ////////////////////////////////////////////////////////////////////////// + + bool operator() (value_null const& lhs, value_unicode_string const& rhs) const + { + return Op::apply(lhs, rhs); + } + ////////////////////////////////////////////////////////////////////////// + + // same types template bool operator() (T lhs, T rhs) const