Last modified: 2012-11-20 11:20:17 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.
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.
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 }}