Skip to content

Commit a247e35

Browse files
fix WOQL.select and WOQL.distinct with variables (#271)
Co-authored-by: Francesca-Bit <francesca@terminusdb.com>
1 parent 5894472 commit a247e35

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/query/woqlQuery.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,6 @@ WOQLQuery.prototype.comment = function (comment, subquery) {
312312
*/
313313

314314
WOQLQuery.prototype.select = function (...varNames) {
315-
// if (list && list[0] === 'args')
316-
// return ['variable_list', 'query']
317315
if (this.cursor['@type']) this.wrapCursorWithAnd();
318316
this.cursor['@type'] = 'Select';
319317
if (!varNames || varNames.length <= 0) {
@@ -324,7 +322,7 @@ WOQLQuery.prototype.select = function (...varNames) {
324322
*@type {any}
325323
*/
326324
let embedquery = false;
327-
if (typeof last === 'object' && last.json) {
325+
if (typeof last === 'object' && !(last instanceof Var) && last.json) {
328326
embedquery = varNames.pop();
329327
} // else var embedquery = false
330328
this.cursor.variables = this.rawVarList(varNames);
@@ -350,7 +348,7 @@ WOQLQuery.prototype.distinct = function (...varNames) {
350348
* @type {any}
351349
*/
352350
let embedquery = false;
353-
if (typeof last === 'object' && last.json) {
351+
if (typeof last === 'object' && !(last instanceof Var) && last.json) {
354352
embedquery = varNames.pop();
355353
} // else var embedquery = false
356354
this.cursor.variables = this.rawVarList(varNames);

0 commit comments

Comments
 (0)