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


Author: dan.bolser

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

bzimport added a subscriber: Unknown Object (MLST).
bzimport set Reference to bz31269.
bzimport created this task.Via LegacySep 30 2011, 10:18 AM
bzimport added a comment.Via ConduitSep 30 2011, 10:31 AM

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).

JeroenDeDauw added a comment.Via ConduitSep 30 2011, 3:04 PM

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

JeroenDeDauw added a comment.Via ConduitApr 8 2012, 4:33 PM

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.
bzimport added a comment.Via ConduitSep 6 2012, 1:20 PM

fpanico wrote:

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

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

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



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

{{#arraydiff:x |all |onlyfull }}

Application with no 'user' and 'owner': {{#arrayprint:x ||@ |@ |print=pretty }}

Aklapper closed this task as "Declined".Via WebMar 3 2015, 5:50 PM
Aklapper added a subscriber: Aklapper.

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.

Add Comment