[Geoserver-devel] [JIRA] (GEOS-10749) Multiple viewparams not working: &viewparams=p1:5; p2:6; p3:7

Peter Smythe created an issue

GeoServer / BugGEOS-10749

Multiple viewparams not working: &viewparams=p1:5;p2:6;p3:7

Issue Type:

BugBug

Affects Versions:

2.21.1

Assignee:

Unassigned

Created:

15/Nov/22 8:47 AM

Priority:

MediumMedium

Reporter:

Peter Smythe

I am following the documentation at https://docs.geoserver.org/latest/en/user/data/database/sqlview.html#using-a-parametric-sql-view which is essentially:

Using a parametric SQL View

The SQL view parameters are specified by adding the viewparams parameter to the WMS GetMap or the WFS GetFeature request. The viewparams argument is a list of key:value pairs, separated by semicolons:

viewparams=p1:v1;p2:v2;...

If the values contain semicolons or commas these must be escaped with a backslash (e.g. \, and \;).

I have discovered that the second and third viewparams (p2, p3 above) do not get set to the values provided in the WFS request and default to their default values.

How to reproduce:

Add store > Geopackage (which allows a SQL view) > test-viewparams as the store name and geopackage name
You will be taken to Add new layer > Configure new SQL view > add a view name and this SQL:

SELECT %p1% as a,
%p2% as b,
%p3% as c
Click Guess parameters from SQL > enter default values 1, 2, 3 respectively. Save, Save.

Now hit
http://localhost:8080/geoserver/wfs?version=1.0.0&request=GetFeature&typeName=cite:test-viewparams&outputFormat=application/json&viewparams=p1:5;p2:6;p3:7

This should set:

  • p1 to 5 (not the default 1)
  • p2 to 6 (not the default 2)
  • p3 to 7 (not the default 3)

However, only p1 is set and p2 and p3 are set to their default values:

{
“type”: “FeatureCollection”,
“features”: [{
“type”: “Feature”,
“id”: “test-viewparams.fid-42816c8f_1842d011d2b_-7ff3”,
“geometry”: null,
“properties”:

Unknown macro: { “a”}

}
],
“totalFeatures”: 1,
“numberMatched”: 1,
“numberReturned”: 1,
“timeStamp”: “2022-11-10T09:29:59.900Z”,
“crs”: null
}

Further, in the GeoServer application logs, I see that the semicolon separator has been replaced by an ampersand separator by the time of “Checking match of request” in the Filter Chains:

15 041 07:41:49 DEBUG [geoserver.security] - Checking match of request : ‘Path: /wfs, QueryString: version=1.0.0&request=GetFeature&typeName=cite:test-viewparams&outputFormat=application/json&viewparams=p1:5*&p2:6&p3:7’; against '/web/*’

And a bit further on only the first viewparams is displayed - the others have already been dropped:

15 041 07:41:49 INFO [geoserver.wfs] -
Request: getFeature
service = WFS
version = 1.0.0
baseUrl = http://localhost:8080/geoserver/
query[0]:
typeName[0] =

{[http://www.opengeospatial.net/cite}

test-viewparams|http://www.opengeospatial.net/cite}test-viewparams]
outputFormat = application/json
resultType = results
viewParams[0] = {P1=5}

Add Comment

Add Comment

Get Jira notifications on your phone! Download the Jira Cloud app for Android or iOS


This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100210-sha1:28a3636)

Atlassian logo