Page MenuHomePhabricator

WDQS should not add (...) to VALUES
Open, Needs TriagePublic

Description

In WDQS, pressing the diamond autoformats this:

SELECT * WHERE {
  VALUES ?a { wd:Q1 wd:Q2 }
}

into this:

SELECT * WHERE {
  VALUES (?a) {
    (wd:Q1)
    (wd:Q2)
  }
}

I think the extra parentesis produce more harm than good. Most of the time, VALUES is a relatively short single-value list, not a list of lists, so making it one item per line creates unnecessary hindrance to understanding and maintaining the query code. Thanks!

Upstream issue: #68

Event Timeline

Yurik created this task.Nov 29 2018, 3:48 AM
Restricted Application added a project: Wikidata. · View Herald TranscriptNov 29 2018, 3:48 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I feel like two things are being conflated here… there are two changes made by the automatic formatting: the variable and values are parenthesized, and the list is split across multiple lines. The title and the beginning of the task description only talk about the parentheses, but then the rationale only explains why the multi-line change is bad…

In either case, this would require improvements in the SPARQL.js library.

Yurik added a comment.Nov 30 2018, 6:07 PM

@Lucas_Werkmeister_WMDE I think both should be fixed - it should never use unneeded parenthesis for single values, and when the VALUES list is short enough, it should be shown singleline. For a very long list, it should be shown like this:

SELECT * WHERE {
  VALUES ?a {
    wd:Q1 wd:Q2 wd:Q1 wd:Q2 wd:Q1 wd:Q2 wd:Q1 wd:Q2 wd:Q1 wd:Q2 wd:Q1 wd:Q2
    wd:Q1 wd:Q2 wd:Q1 wd:Q2 wd:Q1 wd:Q2 wd:Q1 wd:Q2 wd:Q1 wd:Q2 wd:Q1 wd:Q2
  }
}

I guess this is really an upstream request, but we could track it here as well to either encourage upstream to see it, or for someone in WDQS community to tackle it.

Yurik updated the task description. (Show Details)Nov 30 2018, 6:26 PM