Page MenuHomePhabricator

pywikibot.data.sparql SparqlQuery.select() crashes on OPTIONAL values
Closed, ResolvedPublic

Description

The select function in SparqlQuery assumes that are values are set. When you do an optional query like " SELECT ?item ?id ?url WHERE { ?item wdt:P217 ?id . ?item wdt:P195 wd:Q190804 . OPTIONAL { ?item wdt:P973 ?url } } ", this is not always the case.

At https://phabricator.wikimedia.org/diffusion/PWBC/browse/master/pywikibot/data/sparql.py;6b8c01db75d34bef119661584d3ff5de53c35ba9$67 :

for var in qvars:
Check if var is in row, if it's true, do the normal things, if it's not true, set it to None?

Event Timeline

Change 322648 had a related patch set uploaded (by Gerrit Patch Uploader):
T150521: Don't crash on queries with optional values

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

Change 322648 merged by jenkins-bot:
T150521: Don't crash on queries with optional values

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

Multichill claimed this task.
Multichill removed a project: Patch-For-Review.