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

Unexpected query results displayed when using property comparators on multiple values for the same field (#arraymap) #5552

Open
ckapop opened this issue Nov 6, 2023 · 3 comments
Labels
bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error

Comments

@ckapop
Copy link

ckapop commented Nov 6, 2023

Setup

  • SMW version: 3.2.3 (4b579c4)
  • MW version: 1.35.5 (0cc179c)
  • PHP version: 7.4.33 (apache2handler)
  • DB system (MySQL, Blazegraph, etc.) and version: PostgreSQL 10.16 (Debian 10.16-1.pgdg90+1)

Issue

When you have a Page Form that defines a field using an #arraymap and perform an ask query that contains search operators such as equal, not equal, like and not like, unexpected results are returned. For example, it appears when using like all items in the #arraymap are returned instead of just the matched item. When using not like all items in the #arraymap are excluded from the results including unmatched items.

Steps to reproduce the observation (recommendation is to use the sandbox):
Example: https://sandbox.semantic-mediawiki.net/wiki/PetTest

@ckapop ckapop added the bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error label Nov 6, 2023
@D-Groenewegen
Copy link
Contributor

I don't see anything untoward, actually.

  • The #arraymap parser function works as expected. This has no bearing on anything other than how values are stored and presented on the page.
  • The query with [[Has current pets::~*Other*]] - meaning any page with a value containing 'Other' for the Has current pets property - returns the correct page (MyPets3)
  • The next query, with [[Has current pets::!~*Other*]], returns the appropriate pages (MyPets1, MyPets2). It means any page using the Has current pets property that does NOT have values containing 'Other' for this property.
  • The first chart, again [[Has current pets::!~*Other*]], shows data from MyPets1 and MyPets2 only.
  • The second chart, [[Has current pets::!~*Dog*]], shows data from MyPets3 only because MyPets1 and MyPets2 do have values containing the phrase. So your comment "should have 2 Cat and 2 Fish" is not actually true.

You seem to be misunderstanding how queries work. Search operators are about selecting pages, not creating filters on query results if that is what you were trying to achieve.

@ckapop
Copy link
Author

ckapop commented Nov 20, 2023

Thanks for the explanation. We are in fact trying to filter results. Is there a way to filter?

@D-Groenewegen
Copy link
Contributor

Sorry, I did not see your message appear here.

To filter results, you can simply combine them. For instance, [[Has current pets::Other]] [[Has current pets::!Dog]] [[Has current pets::!Bird]] means you're selecting any page that has "Other" as a value of that property, but not "Dog" and not "Bird". And if you just need a list of unique values, you use an inverse query like[[-Has current pets::+]] provided that the property is of type Page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error
Projects
None yet
Development

No branches or pull requests

3 participants
@ckapop @D-Groenewegen and others