SQL view parameter expansion will only replace the first parameter occurrence

Activity

Andrea Aime 
February 15, 2017 at 11:47 AM

Mass closing all resolved issues not modified in the last 4 weeks

Andrea Aime 
October 13, 2015 at 12:05 PM

Yep, let's mark as not a bug

Brad Hards 
October 13, 2015 at 10:57 AM

FWIW, I didn't find the question very clear either.

NOTABUG for this ticket?

Andrea Aime 
October 13, 2015 at 10:24 AM

Hum you're right, I misinterpreted replace vs replaceAll (but it seems the first replaces all occurrences nevertheless). Then I guess I don't understand the issue on stackoverflow?

Brad Hards 
October 13, 2015 at 10:21 AM

I tried to reproduce this with the following unit tests:

--- a/src/wfs/src/test/java/org/geoserver/wfs/SQLViewTest.java +++ b/src/wfs/src/test/java/org/geoserver/wfs/SQLViewTest.java @@ -90,6 +90,18 @@ public class SQLViewTest extends WFSTestSupport { FeatureTypeInfo vft = cb.buildFeatureType(jds.getFeatureSource(vt.getName())); vft.getMetadata().put(FeatureTypeInfo.JDBC_VIRTUAL_TABLE, vt); cat.add(vft); + + // Add a second view that duplicates the name parameter + VirtualTable vt2 = new VirtualTable("geos7242", "select \"name\", \"pointProperty\" from \"pgeo\" where \"booleanProperty\" = %bool% and \"name\" = '%name%' or \"description\" = '%nam + vt2.addParameter(new VirtualTableParameter("bool", "true")); + vt2.addParameter(new VirtualTableParameter("name", "name-f001")); + vt2.addGeometryMetadatata("pointProperty", Point.class, 4326); + jds.addVirtualTable(vt2); + + FeatureTypeInfo vft2 = cb.buildFeatureType(jds.getFeatureSource(vt2.getName())); + vft2.getMetadata().put(FeatureTypeInfo.JDBC_VIRTUAL_TABLE, vt2); + cat.add(vft2); + } /** @@ -181,4 +193,20 @@ public class SQLViewTest extends WFSTestSupport { assertEquals(features.item(0).getFirstChild().getNodeName(), "gml:name"); assertEquals(features.item(0).getFirstChild().getTextContent(), "name-f003"); } + + @Test + public void testGeos7242_1() throws Exception { + Document dom = getAsDOM("wfs?service=WFS&request=GetFeature&typename=gs:geos7242&version=1.1&viewparams=bool:true;name:name-f003"); + + assertXpathEvaluatesTo("name-f003", "//gs:geos7242/gml:name", dom); + assertXpathEvaluatesTo("1", "count(//gs:geos7242)", dom); + } + + @Test + public void testGeos7242_2() throws Exception { + Document dom = getAsDOM("wfs?service=WFS&request=GetFeature&typename=gs:geos7242&version=1.1&viewparams=bool:true;name:description-f002"); + + assertXpathEvaluatesTo("name-f002", "//gs:geos7242/gml:name", dom); + assertXpathEvaluatesTo("1", "count(//gs:geos7242)", dom); + } }

However the tests pass. Am I missing something here?

Not a Bug

Details

Assignee

Reporter

Priority

Created October 12, 2015 at 8:32 PM
Updated February 15, 2017 at 11:47 AM
Resolved October 13, 2015 at 12:05 PM