Programmatically set LIMIT in SPARQL query #5116
-
| Current BehaviorI would like to limit the results of the query and I would like to pass the limit parameter as a variable. I use RDF4JTemplate from rdf4j-spring (and Kotlin). This is the query string: And this is the code that run this query: I got this error:  | 
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
| As per the specification, limit only accepts an integer literal: https://www.w3.org/TR/sparql11-query/#rLimitClause | 
Beta Was this translation helpful? Give feedback.
-
| ... so I don't believe it's a bug, or is it? | 
Beta Was this translation helpful? Give feedback.
-
| 
 @fkleedorfer with SparqlBuilder it is possible to specify the limit with the  | 
Beta Was this translation helpful? Give feedback.
-
| This should work. It's not pretty, though. We may want to add a way to add anonymous blank nodes in a triple pattern. this prints  | 
Beta Was this translation helpful? Give feedback.
-
| The purpose of binding variables at query time is primarily to inject unsafe values and mitigate attacks equivalent to SQL-injection. For values you know are safe you can always revert to doing a simple search/replace on the query string. Just use a unique variable name such as one based off a UUID. | 
Beta Was this translation helpful? Give feedback.
-
| We can rename this issue to be about the SparqlBuilder if that makes more sense. | 
Beta Was this translation helpful? Give feedback.
-
| Apart from its developer experience being quite puzzling at times, the problem here is that the SparqlBuilder does not allow you to specify anonymous blank nodes with predicate-object lists. That would be a relatively simple addition, I believe. | 
Beta Was this translation helpful? Give feedback.
-
| Just to make sure your problem is solved @gdeak-monguz, did this SparqlBuilder solution work for you ? | 
Beta Was this translation helpful? Give feedback.
-
| 
 Yes, thank you for your help! | 
Beta Was this translation helpful? Give feedback.
This should work. It's not pretty, though. We may want to add a way to add anonymous blank nodes in a triple pattern.