Skip to content

Commit

Permalink
Support string variables.
Browse files Browse the repository at this point in the history
Fixes #180
  • Loading branch information
RubenVerborgh committed Aug 23, 2024
1 parent 44a30f5 commit bbf4120
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/SparqlGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,16 @@ Generator.prototype.toQuery = function (q) {

if (q.variables){
query += mapJoin(q.variables, undefined, function (variable) {
return isTerm(variable) ? this.toEntity(variable) :
'(' + this.toExpression(variable.expression) + ' AS ' + variableToString(variable.variable) + ')';
// String variable
if (/^[?$]/.test(variable))
return variable;
// Entity object
else if (isTerm(variable))
return this.toEntity(variable);
// Expression object
else
return '(' + this.toExpression(variable.expression) +
' AS ' + variableToString(variable.variable) + ')';
}, this) + ' ';
}
else if (q.template)
Expand Down

0 comments on commit bbf4120

Please sign in to comment.