Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string functions produces unquoted string literals #1175

Closed
aindlq opened this issue Dec 6, 2023 · 4 comments
Closed

string functions produces unquoted string literals #1175

aindlq opened this issue Dec 6, 2023 · 4 comments

Comments

@aindlq
Copy link

aindlq commented Dec 6, 2023

CONSTRUCT {
  <http://example.com> <http://example.com/label> ?value
} WHERE {
  BIND(CONCAT("A", "," , "B") AS ?value).
}

Getting turtle with curl:

curl 'https://qlever.cs.uni-freiburg.de/api/wikidata' -X POST -H 'Accept: text/turtle' -H 'Content-Type: application/x-www-form-urlencoded' --data-raw 'query=CONSTRUCT+%7B%0A++%3Chttp%3A%2F%2Fexample.com%3E+%3Chttp%3A%2F%2Fexample.com%2Flabel%3E+%3Fvalue%0A%7D+WHERE+%7B%0A++BIND(CONCAT(%22A%22%2C++%22%2C%22+%2C+%22B%22)++AS+%3Fvalue).%0A%7D&send=969'

Produces:

<http://example.com> <http://example.com/label> A,B .

But should be:

<http://example.com> <http://example.com/label> "A,B" .
@aindlq
Copy link
Author

aindlq commented Dec 6, 2023

Workaround is to "add" quotes:

CONSTRUCT {
  <http://example.com> <http://example.com/label> ?value
} WHERE {
  BIND(CONCAT("\"",  "A", "," , "B",  "\"") AS ?value).
}
<http://example.com> <http://example.com/label> "A,B" .

@aindlq
Copy link
Author

aindlq commented Dec 6, 2023

Apparently it is with all string functions, not only CONCAT. But all string functions, even STR.

CONSTRUCT {
  <http://example.com> <http://example.com/label> ?value
} WHERE {
  BIND(REPLACE("AA", "A",  "B") AS ?value).
}
<http://example.com> <http://example.com/label> BB .

STR

CONSTRUCT {
  <http://example.com> <http://example.com/label> ?a .
  <http://example.com> <http://example.com/label> ?b .
} WHERE {
  BIND("A" AS ?a) .
  BIND(STR(?a) AS ?b).
}
<http://example.com> <http://example.com/label> "A" .
<http://example.com> <http://example.com/label> A .

@aindlq aindlq changed the title CONCAT function produces unquoted string literals string functions produces unquoted string literals Dec 6, 2023
@aindlq
Copy link
Author

aindlq commented Dec 6, 2023

Also looks like in some situations STR produce wrong string for URI.

CONSTRUCT {
  <http://example.com> <http://example.com/label> ?b .
} WHERE {
  BIND(STR(<http://example.com/A>) AS ?b).
}
<http://example.com> <http://example.com/label> <http://example.com/A> .

I believe the resulting value, even taking quotes bug into account, shouldn't have < and >.

@joka921
Copy link
Member

joka921 commented May 3, 2024

Thanks for reporting this.
We now handle these cases much more correctly and all of your queries were fixed by #1333 and #1318.

Note that there still might be some inaccuracies wrt to escaping in the various output formats, but the bugs that were responsible for the issues you reported should now all be fixed.

@joka921 joka921 closed this as completed May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants