Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter ["all",["==",["geometry-type"],"Polygon"],["!",["has","lp"]]] is prohibited by validation #7730

Closed
gorshkov-leonid opened this issue Dec 27, 2018 · 6 comments

Comments

@gorshkov-leonid
Copy link
Contributor

gorshkov-leonid commented Dec 27, 2018

mapbox-gl-js version:
0.51.0

browser:
all

Description:
We used filter ["all",["==","$type","Polygon"],["!has","lp"]] it worked. But when this filter was wrapped by another filter some error threw. As I understand we are using deprecated syntax and it is root cause.

I tried to fix filter to ["all",["==","$type","Polygon"],["!",["has","lp"]]] and got error
expected [==, !=, >, >=, <, <=, in, !in, all, any, none, has, !has], "!" found

You can say that this expression is using deprecated syntax ["==","$type","Polygon"]. Ok I changed it to ["all",["==",["get","$type"],"Polygon"],["!",["has","lp"]]] and got error
string expected, array found (it is about ["get","$type"]).

You can say that this expression is using deprecated syntax $type. Ok I tried to use "geometry-type", but got error again

image

I tried also
["all",["match",["geometry-type"],["Polygon"],true,false],["!",["has","lp"]]] as in test in feature_filter.test.js but got error expected one of [==, !=, >, >=, <, <=, in, !in, all, any, none, has, !has], "match" found

It looks like test in feature_filter.test.js and comment

Could you say me, is it a bug?
I read documentation about "get", "has", "!", "==", "all", "geometry-type". Last expression seems correct, but It does not work:

["all",["==",["geometry-type"],"Polygon"],["!",["has","lp"]]]

Is it related to #7699, #7679 ?

@gorshkov-leonid gorshkov-leonid changed the title Filter ["all",["==",["get","$type"],"Polygon"],["!",["has","abc"]]] is prohibited by validation Filter ["all",["==",["geometry-type"],"Polygon"],["!",["has","lp"]]] is prohibited by validation Dec 27, 2018
@mourner
Copy link
Member

mourner commented Jan 2, 2019

Can you please set up a minimal test case (e.g. on JSFiddle) reproducing the issue?

@gorshkov-leonid
Copy link
Contributor Author

gorshkov-leonid commented Jan 5, 2019

Hello @mourner. Sorry for bother. I did not reproduce that error. May be I got wrong with this expression. I tried to debug with only breakpoint in constructor of ValidationError.

So first error was occured by filter expression ["all",["==",["geometry-type"],"LineString"],["any",["==","sp","_"],["all",["!has","sp"],["any",["!has","sp"],["==","sp","_"]]]]] (https://jsfiddle.net/goleon/sj40agth/) . Hm !has is deprecated too.

I tried to fix expression: ["all",["==",["geometry-type"],"LineString"],["any",["==","sp","_"],["all",["!",["has","sp"]],["any",["!",["has","sp"]],["==","sp","_"]]]]] but got errors string expected, array found, expected one of [==, !=, >, >=, <, <=, in, !in, all, any, none, has, !has], "!" found (https://jsfiddle.net/goleon/nup8gL9q/)

Yet another example: https://jsfiddle.net/goleon/k0uharpq/.

Working expressions:

["all",["==",["geometry-type"],"Polygon"],["!",["has","lp"]]]
["all",
       ["==", ["geometry-type"],"Polygon"],
       ["any",  
            ["!",["has","sp"]] 
       ]
]

Not working expressions:

["any",
      ["==","sp","_"],
      ["!",["has","sp"]]
 ]
["all",
   ["==", ["geometry-type"],"Polygon"],
   ["any",
        ["==","sp","_"],
        ["!",["has","sp"]]
   ]
]

@gorshkov-leonid
Copy link
Contributor Author

Any updates?

@gorshkov-leonid
Copy link
Contributor Author

Hello @mourner, do you have any news. Did you accept these things as bugs?

@mourner
Copy link
Member

mourner commented Jan 28, 2019

I've looked through all the examples and I think you're just mixing legacy filter syntax and the new expression syntax in all of them. In the case of the last "not working" examples, the culprit is ["==","sp","_"] — since you're comparing two literal strings (and not e.g. ["==", ["get", "sp"], "_"]), GL JS thinks this is a legacy filter, but then fails to parse it because it has things from the expression system (such as ["geometry-type"]).

@mourner mourner closed this as completed Jan 28, 2019
@TannerPerrien
Copy link
Contributor

I just stumbled upon this trying to figure out why certain combinations of expressions weren't working. Is there any documentation that outlines legacy vs non-legacy? I looked in the docs for this but ended up not finding anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants