We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This code:
String prepare(final String unprepared) { final MapBindingSet mbs = new MapBindingSet(); mbs.addBinding("iri", Values.iri("https://www.youtube.com/watch?v=dQw4w9WgXcQ")); return QueryStringUtil.getGraphQueryString(unprepared, mbs); }
yields these results:
System.out.println(prepare("DESCRIBE ?iri")); // => DESCRIBE ?iri System.out.println(prepare("DESCRIBE ?iri ")); // => DESCRIBE <https://www.youtube.com/watch?v=dQw4w9WgXcQ>
This appears to be because the pattern to replace is
String pattern = "[\\?\\$]" + name + "(?=\\W)";
which demands some non-word character after the variable.
System.out.println(prepare("DESCRIBE ?iri")); // => DESCRIBE <https://www.youtube.com/watch?v=dQw4w9WgXcQ> System.out.println(prepare("DESCRIBE ?iri ")); // => DESCRIBE <https://www.youtube.com/watch?v=dQw4w9WgXcQ>
Self-contained test:
import org.eclipse.rdf4j.model.util.Values; import org.eclipse.rdf4j.query.impl.MapBindingSet; import org.eclipse.rdf4j.repository.sparql.query.QueryStringUtil; import org.junit.Test; public class TestQueryStrings { @Test public void testPrepare() { // Works when variable is followed by space assertEquals("DESCRIBE <https://www.youtube.com/watch?v=dQw4w9WgXcQ> ", prepare("DESCRIBE ?iri ")); // Fails when variable is at end of input assertEquals("DESCRIBE <https://www.youtube.com/watch?v=dQw4w9WgXcQ>", prepare("DESCRIBE ?iri")); } String prepare(final String unprepared) { final MapBindingSet mbs = new MapBindingSet(); mbs.addBinding("iri", Values.iri("https://www.youtube.com/watch?v=dQw4w9WgXcQ")); return QueryStringUtil.getGraphQueryString(unprepared, mbs); } private static <T> void assertEquals(final T expected, final T actual) { if (!expected.equals(actual)) { throw new AssertionError("Expected '" + expected + "' but got '" + actual + "'"); } } }
4.3.6
Perhaps?
No response
The text was updated successfully, but these errors were encountered:
\b would be better here indeed.
\b
Sorry, something went wrong.
No branches or pull requests
Current Behavior
This code:
yields these results:
This appears to be because the pattern to replace is
which demands some non-word character after the variable.
Expected Behavior
Steps To Reproduce
Self-contained test:
Version
4.3.6
Are you interested in contributing a solution yourself?
Perhaps?
Anything else?
No response
The text was updated successfully, but these errors were encountered: