Page MenuHomePhabricator

Using the same property in different conditions with regardless of value generates malformed SPARQL query
Closed, ResolvedPublic5 Estimated Story PointsBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • select property P18 (image) it is automatically regardless of value)
  • create a different property and unite with OR or AND again with P18
  • click "Run Query" button

Example in QB

Actual Results (what happens?):

Error: Query is malformed: BNodeID already used in another scope: anyValueP18 because

anyValueP18 should have an index. should be anyValueP18_0 and anyValueP18_1:

SELECT DISTINCT ?item WHERE {
      {
        ?item p:P281 ?statement0.
        ?statement0 (ps:P281) "6200".
      }
      UNION
      {
        ?item p:P18 ?statement1.
        ?statement1 (ps:P18) _:anyValueP18.
      }
      {
        ?item p:P30 ?statement2.
        ?statement2 (ps:P30/(wdt:P279*)) wd:Q46.
      }
      UNION
      {
        ?item p:P18 ?statement3.
        ?statement3 (ps:P18) _:anyValueP18.
      }
    }
    LIMIT 100

Expected Results (what should have happened?):

The following SPARQL should have been generated

SELECT DISTINCT ?item WHERE {
      {
        ?item p:P281 ?statement0.
        ?statement0 (ps:P281) "6200".
      }
      UNION
      {
        ?item p:P18 ?statement1.
        ?statement1 (ps:P18) _:anyValueP18_0.
      }
      {
        ?item p:P30 ?statement2.
        ?statement2 (ps:P30/(wdt:P279*)) wd:Q46.
      }
      UNION
      {
        ?item p:P18 ?statement3.
        ?statement3 (ps:P18) _:anyValueP18_1.
      }
    }
    LIMIT 100

Related Objects

Mentioned Here
P18 my paste!

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 682684 had a related patch set uploaded (by Tonina Zhelyazkova; author: Tonina Zhelyazkova):

[wikidata/query-builder@master] Index repeating property IDs in the sparql query

https://gerrit.wikimedia.org/r/682684

Change 684889 had a related patch set uploaded (by Tonina Zhelyazkova; author: Tonina Zhelyazkova):

[wikidata/query-builder@master] Add an index to all 'anyValue' occurrences

https://gerrit.wikimedia.org/r/684889

Change 684912 had a related patch set uploaded (by Tonina Zhelyazkova; author: Tonina Zhelyazkova):

[wikidata/query-builder@master] Add an index to repeating properties of any value

https://gerrit.wikimedia.org/r/684912

Change 684912 merged by jenkins-bot:

[wikidata/query-builder@master] Add an index to repeating properties of any value

https://gerrit.wikimedia.org/r/684912