WolfgangFahl / py-3rdparty-mediawiki

Wrapper for pywikibot and mwclient MediaWiki API librarties with improvements for 3rd party wikis
Apache License 2.0
4 stars 5 forks source link

fixAsk alters the query semantic #82

Closed tholzheim closed 2 years ago

tholzheim commented 2 years ago

https://github.com/WolfgangFahl/py-3rdparty-mediawiki/blob/da18038b3d5679407726de31fe9ad1943be19840/wikibot/smw.py#L248

Input

{{#ask:[[IsA::Event series]]
|mainlabel=pageTitle
|?EventSeries_acronym=acronym
}}

Output

[[IsA::Event_series]]
|mainlabel=pageTitle
|?EventSeries_acronym=acronym

Expected Output

[[IsA::Event series]]
|mainlabel=pageTitle
|?EventSeries_acronym=acronym

Bug

We query for the string Event series which is escaped to Event_series which is only allowed for values of type Page. Since fixAsk()main purpose is to remove the {{#ask: ...}} circumfix and to remove the white space the replacement of blanks with an underscore should be removed or replaced by escaping a blank with %20

https://github.com/WolfgangFahl/py-3rdparty-mediawiki/blob/da18038b3d5679407726de31fe9ad1943be19840/wikibot/smw.py#L273

WolfgangFahl commented 2 years ago

What is an example for when this behavior is incorrect? Please specify situation, action and expected result.

tholzheim commented 2 years ago

I updated the issue description. The problem is that if the value of the selector has datatype Page the escaping with the underscore is correct. If the property has datatype string escaping the blank with the underscore alters the selector string and thus the query result

WolfgangFahl commented 2 years ago

identifiers with blanks are evil :-)