Apologies, this is not a GeoServer issue, but rather an AWS (WAF?) problem
which replaces the semicolon with an ampersand before the request even
reaches GeoServer. The workaround, before we delve further in the AWS WAF,
is to URL-encode the semicolon with %3B. GeoServer then sees all 3
viewparams correctly.
Peter

On Sun, 13 Nov 2022 at 17:45, Peter Smythe <g...@smythe.co.za> wrote:

> Hi all
>
> 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¶
>> <https://docs.geoserver.org/latest/en/user/data/database/sqlview.html#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.
>
> [image: image.png]
>
> 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": {
>>                 "a": 5,
>>                 "b": 2,
>>                 "c": 3
>>             }
>>         }
>>     ],
>>     "totalFeatures": 1,
>>     "numberMatched": 1,
>>     "numberReturned": 1,
>>     "timeStamp": "2022-11-10T09:29:59.900Z",
>>     "crs": null
>> }
>>
>
> Can anyone explain why this is not working, please?
>
> Thank you
>
> Peter
>

_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to