Last modified: 2012-11-20 11:20:17 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T33269, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 31269 - Query (ask) for pages where a property isn't set?
Query (ask) for pages where a property isn't set?
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Unprioritized enhancement with 3 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-30 10:18 UTC by Dan Bolser
Modified: 2012-11-20 11:20 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Dan Bolser 2011-09-30 10:18:46 UTC
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.
Comment 1 Dan Bolser 2011-09-30 10:31:59 UTC
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).
Comment 2 Jeroen De Dauw 2011-09-30 15:04:45 UTC
I agree with the syntax, and the usefulness of such a feature in general. Should not be to difficult to implement actually.
Comment 3 Jeroen De Dauw 2012-04-08 16:33:52 UTC
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.
Comment 4 Francesco Panico 2012-09-06 13:20:03 UTC
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}}

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

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links