Page MenuHomePhabricator

Query (ask) for pages where a property isn't set?
Closed, DeclinedPublic

Description

Author: dan.bolser

Description:
It would be good if you could query for pages where a certain property has not been set to any value.

For example:

I would like a query that will list the pages that have ended up with no value set for these properties, so I can check whether a user has made a mistake or if we really no longer need that resource. But I can't work out how to do it...

It would still be nice to have the equivalent to 'if !isset(x)' available to avoid having to use a dummy NULL value.


Version: unspecified
Severity: enhancement

Details

Reference
bz31269

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 21 2014, 11:50 PM
bzimport set Reference to bz31269.
bzimport added a subscriber: Unknown Object (MLST).

dan.bolser wrote:

I guess a good syntax would be [[Some prop::!]], for example:

{{#ask: [[Category:x]] [[Some prop::!]] }}

This fits with the style of the opposite query for pages where the property is set (to any value):

{{#ask: [[Category:x]] [[Some prop::+]] }}

Just an idea (although I understand the issue here isn't one of suitable syntax, but rather efficiency of SQL).

I agree with the syntax, and the usefulness of such a feature in general. Should not be to difficult to implement actually.

Adding some thoughts since Nichay wants to tackle this bug:

So this feature addition consists of 3 parts

  • Extend the ask language with this new ! syntax. This requires modifying SMWQueryParser and the new code will need to be placed on the same places where the + operator (any values) is located, which you can find by doing a search for '+' (those 3 characters). Currently this is line 187, 271, 331 and 430.
  • Have some new way to represent "property with no value" internally. AFAIK we do not have this yet, but should double check with Markus and ask for his thoughts on best way to implement. Will likely involve creating a new class deriving from SMWDescription or modifying an existing one.
  • Make the store(s) actually handle the new description. If we just want to implement this for MySQL and PostgreSQL, this will involve modifying SMWSQLStore2.

fpanico wrote:

Here there is a Array based workaround .
It is not very performant but it is a workaround.

Question:
If you have an Application Category and you ask for the Application instance with "Has owner" and "Has user" properties empty.

Answare:
Step 1: ask for all Application instances and save the list in "all" named array
Step 2: ask for Application instances with valued "Has owner" and "Has user" properties, and save the list in "onlyfull" named array
Step 3: calculate a new array: "all" minus "onlyfull"
Step 4: print the new array

Code:

{{#ask:[[Category:Application]]|format=array|name=all}}

{{#ask:[[Category:Application]][[Has owner::+]][[Has user::+]]|format=array|name=onlyfull}}

Aklapper subscribed.

The Semantic MediaWiki developers requested in https://phabricator.wikimedia.org/T64114 to move their task tracking to https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues and to close remaining tasks in Wikimedia Phabricator. If you still face the problem reported in this task in a supported version of SMW, please feel free to transfer your report to https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues . We are sorry for the inconvenience.