jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1336198?usp=email )

Change subject: sparql: Preserve existing endpoint query parameters
......................................................................

sparql: Preserve existing endpoint query parameters

Appending a question mark unconditionally folds the SPARQL query into
an existing endpoint parameter instead of creating a query parameter.

Append the encoded query to the parsed URL query component, preserving
existing parameters and placing it before any fragment. Keep the current
SPARQL encoding for endpoints without parameters.

Change-Id: I3453f66edac4f1bf6890f0d3e36c062cc3fe6bba
---
M pywikibot/data/sparql.py
1 file changed, 5 insertions(+), 1 deletion(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/pywikibot/data/sparql.py b/pywikibot/data/sparql.py
index 41ab131..29fd989 100644
--- a/pywikibot/data/sparql.py
+++ b/pywikibot/data/sparql.py
@@ -146,7 +146,11 @@
         self.last_response = None
         self.current_retries = 0

-        url = f'{self.endpoint}?query={quote(query)}'
+        endpoint = urlparse(self.endpoint)
+        query_string = f'query={quote(query)}'
+        if endpoint.query:
+            query_string = f'{endpoint.query}&{query_string}'
+        url = endpoint._replace(query=query_string).geturl()
         while True:
             try:
                 self.last_response = cast(Response,

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1336198?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I3453f66edac4f1bf6890f0d3e36c062cc3fe6bba
Gerrit-Change-Number: 1336198
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to