MapServer Expressions and Bracketing

Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

MapServer Expressions and Bracketing

Seth G-2
Hi all,

Not sure if this is more of a dev or user question. The docs for logical expressions state each expression should be encapsulated in round brackets e.g. ( ( Expression1 ) AND ( Expression2 ) ). This is how mappyfile expects them (see issue at [1]), however it seems MapServer is more flexible and allows expressions such as:

EXPRESSION ("[TIME]" eq 'NOW' AND NOT "[TYPE]" ~ "(something|completely|different)")

This should really be:

EXPRESSION (("[TIME]" eq 'NOW') AND NOT ("[TYPE]" ~ "(something|completely|different)"))

So should MapServer 8 become stricter and fail these errors and stick to a tighter spec, or should the docs be updated to reflect the reality of the parsing?

Seth

[1] https://github.com/geographika/mappyfile/issues/85


--
web:http://geographika.co.uk
twitter: @geographika
_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: MapServer Expressions and Bracketing

Lime, Steve D (MNIT)
The docs are wrong or at least confusing IMHO. The only requirement is that the entire logical expression has a whole needs to be encased in a ()'s so the parser can find it. Sub-expressions do not have to be encased in brackets unless it is needed to establish precedence in terms of how the expression is evaluated. MapServer more closely matches SQL and I wouldn't want to limit that. I do think ()'s can help with readability but they aren't required save the outer ()'s. --Steve

-----Original Message-----
From: mapserver-dev [mailto:[hidden email]] On Behalf Of Seth G
Sent: Wednesday, October 09, 2019 1:41 PM
To: [hidden email]
Subject: [mapserver-dev] MapServer Expressions and Bracketing

Hi all,

Not sure if this is more of a dev or user question. The docs for logical expressions state each expression should be encapsulated in round brackets e.g. ( ( Expression1 ) AND ( Expression2 ) ). This is how mappyfile expects them (see issue at [1]), however it seems MapServer is more flexible and allows expressions such as:

EXPRESSION ("[TIME]" eq 'NOW' AND NOT "[TYPE]" ~ "(something|completely|different)")

This should really be:

EXPRESSION (("[TIME]" eq 'NOW') AND NOT ("[TYPE]" ~ "(something|completely|different)"))

So should MapServer 8 become stricter and fail these errors and stick to a tighter spec, or should the docs be updated to reflect the reality of the parsing?

Seth

[1] https://github.com/geographika/mappyfile/issues/85


--
web:http://geographika.co.uk
twitter: @geographika
_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: MapServer Expressions and Bracketing

Daniel Morissette
What Steve wrote was also my understanding, so I'd vote for updating the
docs to match the current behavior (and avoid breaking existing maps).

Daniel

On 2019-10-09 16:11, Lime, Steve D (MNIT) wrote:

> The docs are wrong or at least confusing IMHO. The only requirement is that the entire logical expression has a whole needs to be encased in a ()'s so the parser can find it. Sub-expressions do not have to be encased in brackets unless it is needed to establish precedence in terms of how the expression is evaluated. MapServer more closely matches SQL and I wouldn't want to limit that. I do think ()'s can help with readability but they aren't required save the outer ()'s. --Steve
>
> -----Original Message-----
> From: mapserver-dev [mailto:[hidden email]] On Behalf Of Seth G
> Sent: Wednesday, October 09, 2019 1:41 PM
> To: [hidden email]
> Subject: [mapserver-dev] MapServer Expressions and Bracketing
>
> Hi all,
>
> Not sure if this is more of a dev or user question. The docs for logical expressions state each expression should be encapsulated in round brackets e.g. ( ( Expression1 ) AND ( Expression2 ) ). This is how mappyfile expects them (see issue at [1]), however it seems MapServer is more flexible and allows expressions such as:
>
> EXPRESSION ("[TIME]" eq 'NOW' AND NOT "[TYPE]" ~ "(something|completely|different)")
>
> This should really be:
>
> EXPRESSION (("[TIME]" eq 'NOW') AND NOT ("[TYPE]" ~ "(something|completely|different)"))
>
> So should MapServer 8 become stricter and fail these errors and stick to a tighter spec, or should the docs be updated to reflect the reality of the parsing?
>
> Seth
>
> [1] https://github.com/geographika/mappyfile/issues/85
>
>
> --
> web:http://geographika.co.uk
> twitter: @geographika
> _______________________________________________
> mapserver-dev mailing list
> [hidden email]
> https://lists.osgeo.org/mailman/listinfo/mapserver-dev
> _______________________________________________
> mapserver-dev mailing list
> [hidden email]
> https://lists.osgeo.org/mailman/listinfo/mapserver-dev
>


--
Daniel Morissette
Mapgears Inc
T: +1 418-696-5056 #201
_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: MapServer Expressions and Bracketing

Seth G-2
Hi Steve, Daniel,

Thanks for the clarifications. It makes sense to follow SQL as closesly as possible.
I've made a minor modification to the docs at https://github.com/mapserver/docs/pull/288 to make this clearer.
I've also added some new msautotests with multipart expressions with and without brackets at https://github.com/mapserver/mapserver/pull/5897 - there were no non-bracketed expressions previously as my mappyfile parser was able to parse all Mapfiles without any issues.

Seth

--
web:http://geographika.co.uk
twitter: @geographika

On Wed, Oct 9, 2019, at 10:12 PM, Daniel Morissette wrote:

> What Steve wrote was also my understanding, so I'd vote for updating the
> docs to match the current behavior (and avoid breaking existing maps).
>
> Daniel
>
> On 2019-10-09 16:11, Lime, Steve D (MNIT) wrote:
> > The docs are wrong or at least confusing IMHO. The only requirement is that the entire logical expression has a whole needs to be encased in a ()'s so the parser can find it. Sub-expressions do not have to be encased in brackets unless it is needed to establish precedence in terms of how the expression is evaluated. MapServer more closely matches SQL and I wouldn't want to limit that. I do think ()'s can help with readability but they aren't required save the outer ()'s. --Steve
> >
> > -----Original Message-----
> > From: mapserver-dev [mailto:[hidden email]] On Behalf Of Seth G
> > Sent: Wednesday, October 09, 2019 1:41 PM
> > To: [hidden email]
> > Subject: [mapserver-dev] MapServer Expressions and Bracketing
> >
> > Hi all,
> >
> > Not sure if this is more of a dev or user question. The docs for logical expressions state each expression should be encapsulated in round brackets e.g. ( ( Expression1 ) AND ( Expression2 ) ). This is how mappyfile expects them (see issue at [1]), however it seems MapServer is more flexible and allows expressions such as:
> >
> > EXPRESSION ("[TIME]" eq 'NOW' AND NOT "[TYPE]" ~ "(something|completely|different)")
> >
> > This should really be:
> >
> > EXPRESSION (("[TIME]" eq 'NOW') AND NOT ("[TYPE]" ~ "(something|completely|different)"))
> >
> > So should MapServer 8 become stricter and fail these errors and stick to a tighter spec, or should the docs be updated to reflect the reality of the parsing?
> >
> > Seth
> >
> > [1] https://github.com/geographika/mappyfile/issues/85
> >
> >
> > --
> > web:http://geographika.co.uk
> > twitter: @geographika
> > _______________________________________________
> > mapserver-dev mailing list
> > [hidden email]
> > https://lists.osgeo.org/mailman/listinfo/mapserver-dev
> > _______________________________________________
> > mapserver-dev mailing list
> > [hidden email]
> > https://lists.osgeo.org/mailman/listinfo/mapserver-dev
> >
>
>
> --
> Daniel Morissette
> Mapgears Inc
> T: +1 418-696-5056 #201
> _______________________________________________
> mapserver-dev mailing list
> [hidden email]
> https://lists.osgeo.org/mailman/listinfo/mapserver-dev
_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev