TomT0m created this task.
TomT0m added a project: Wikidata Query UI.
Restricted Application added a subscriber: Aklapper.

TASK DESCRIPTION
  I filled this as a bug but this might be considered a feature request, 
depending on the point of view. (The point is that I considered this as a 
bummer when trying to use the feature)
  
  The "template" feature of WDQS is useful, but there is a stopper that make it 
hard to use for some query. It requires a variable to "bind" a value, and that 
works only in some scope of a query.
  
  If you write a complex query, the variable is likely to not be accessible in 
all the scopes.
  
  See for example this query
  
    #TEMPLATE={ "template": { "en": "Textual description of template, 
referencing ?var" }, "variables": { "?var": {  } } }
    
    select * {
      
      bind ( wd:Q5 as ?var)
      
      ?person wdt:P31 ?var .
      
      {
        select ?person2 (?var as ?plop){
          ?person2 wdt:P31 ?var  .
          bind ( wd:Q5 as ?var)
        } limit 10
      }
    } limit 100 
  
  that can be checked 
(here)[https://query.wikidata.org/embed.html#%23TEMPLATE%3D%7B%20%22template%22%3A%20%7B%20%22en%22%3A%20%22Textual%20description%20of%20template%2C%20referencing%20%3Fvar%22%20%7D%2C%20%22variables%22%3A%20%7B%20%22%3Fvar%22%3A%20%7B%20%20%7D%20%7D%20%7D%0ASELECT%20*%20WHERE%20%7B%0A%20%20BIND(wd%3AQ571%20AS%20%3Fvar)%0A%20%20%3Fperson%20wdt%3AP31%20%3Fvar.%0A%20%20%7B%0A%20%20%20%20SELECT%20%3Fperson2%20(%3Fvar%20AS%20%3Fplop)%20WHERE%20%7B%0A%20%20%20%20%20%20%3Fperson2%20wdt%3AP31%20%3Fvar.%0A%20%20%20%20%20%20BIND(wd%3AQ5%20AS%20%3Fvar)%0A%20%20%20%20%7D%0A%20%20%20%20LIMIT%2010%0A%20%20%7D%0A%7D%0ALIMIT%20100)]
  
  There is a "bind" in a subquery with the same variable, but when you 
interactively change the "human" value of the "?var" value then the value does 
not change in the subquery. This query is dummy of course, it’s just provided 
here for illustration.
  
  There could be a solution using named subquery, doing the bind in a dummy 
named subquery and include in later in any relevant context, but it’s tedious 
to do, and named subquery tends to sometimes make a query timeout for non 
obvious reasons, which require work to solve.
  
  I see too solutions for this problem :
  
  - either drop the use of a "bind" and instead use the "prefix" feature as 
used in scholia, see 
https://github.com/WDscholia/scholia/blob/master/scholia/app/templates/author_list-of-publications.sparql
 . This solves the scope problem. It can coexist with the current solution by 
adding an option to the template json, or by checking if the "?var" part is 
replaced by a prefix syntax "var:" as it is done in the "prefix" case.
  - Non exclusive, instead of replacing the bind value in only one bind replace 
it in all places, requires putting multiple "binds" in the query, less 
convenient to use.

TASK DETAIL
  https://phabricator.wikimedia.org/T327601

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: TomT0m
Cc: Aklapper, TomT0m, AWesterinen, MPhamWMF, CBogen, Namenlos314, Gq86, 
Lucas_Werkmeister_WMDE, Mahir256, EBjune, merbst, Salgo60, Jonas, Xmlizer, 
jkroll, Wikidata-bugs, Jdouglas, aude, Tobias1984, Manybubbles, Lydia_Pintscher
_______________________________________________
Wikidata-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to