Skip to content

Commit

Permalink
Fix 9605 issue with <> transformed into ogc filter (#9628)
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 authored Oct 19, 2023
1 parent fbe7d0b commit 57088f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion web/client/utils/FilterUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const ogcStringField = (attribute, operator, value, nsplaceholder) => {
attribute +
propertyTagReference[nsplaceholder].endTag
);
} else if (operator === "=") {
} else if (operator === "=" || operator === "<>") {
fieldFilter =
ogcComparisonOperators[operator](nsplaceholder,
propertyTagReference[nsplaceholder].startTag +
Expand Down
9 changes: 9 additions & 0 deletions web/client/utils/__tests__/FilterUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
processOGCCrossLayerFilter,
cqlBooleanField,
cqlStringField,
ogcStringField,
ogcBooleanField,
getCrossLayerCqlFilter,
composeAttributeFilters,
Expand Down Expand Up @@ -1239,6 +1240,14 @@ describe('FilterUtils', () => {
// test LIKE wrapped with wildcard
expect(cqlStringField("attribute_1", "like", "*A*")).toBe("\"attribute_1\" LIKE '%A%'");
});
it('Check if ogcStringField(attribute, operator, value, ns)', () => {
// testing operator =
expect(ogcStringField("attribute_1", "=", "Alabama", "ogc")).toBe("<ogc:PropertyIsEqualTo><ogc:PropertyName>attribute_1</ogc:PropertyName><ogc:Literal>Alabama</ogc:Literal></ogc:PropertyIsEqualTo>");
expect(ogcStringField("attribute_1", "<>", "Alabama", "ogc")).toBe("<ogc:PropertyIsNotEqualTo><ogc:PropertyName>attribute_1</ogc:PropertyName><ogc:Literal>Alabama</ogc:Literal></ogc:PropertyIsNotEqualTo>");
expect(ogcStringField("attribute_1", "like", "Alabama", "ogc")).toBe("<ogc:PropertyIsLike matchCase=\"true\" wildCard=\"*\" singleChar=\".\" escapeChar=\"!\"><ogc:PropertyName>attribute_1</ogc:PropertyName><ogc:Literal>*Alabama*</ogc:Literal></ogc:PropertyIsLike>");
expect(ogcStringField("attribute_1", "ilike", "Alabama", "ogc")).toBe("<ogc:PropertyIsLike matchCase=\"false\" wildCard=\"*\" singleChar=\".\" escapeChar=\"!\"><ogc:PropertyName>attribute_1</ogc:PropertyName><ogc:Literal>*Alabama*</ogc:Literal></ogc:PropertyIsLike>");
expect(ogcStringField("attribute_1", "isNull", "", "ogc")).toBe("<ogc:PropertyIsNull><ogc:PropertyName>attribute_1</ogc:PropertyName></ogc:PropertyIsNull>");
});
it('Check if ogcBooleanField(attribute, operator, value, nsplaceholder)', () => {
// testing operators
expect(ogcBooleanField("attribute_1", "=", true, "ogc"))
Expand Down

0 comments on commit 57088f5

Please sign in to comment.