Skip to content

Commit fcec83b

Browse files
Merge pull request #205 from terminusdb/fix_type_of
Fix type_of
2 parents d3eb2e1 + 802b998 commit fcec83b

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/query/woqlQuery.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,8 +1070,8 @@ WOQLQuery.prototype.type_of = function (a, b) {
10701070
if (!a || !b) return this.parameterError('type_of takes two parameters, both values');
10711071
if (this.cursor['@type']) this.wrapCursorWithAnd();
10721072
this.cursor['@type'] = 'TypeOf';
1073-
this.cursor.value = this.cleanClass(a);
1074-
this.cursor.type = this.cleanClass(b);
1073+
this.cursor.value = this.cleanObject(a);
1074+
this.cursor.type = this.cleanSubject(b);
10751075
return this;
10761076
};
10771077

test/woql.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,4 +364,23 @@ describe('woql queries', () => {
364364

365365
expect(varsArr[0]).to.be.instanceof(Var);
366366
});
367+
368+
it('check type_of(Var,Var)', () => {
369+
const TypeOf = WOQL.type_of('v:X', 'v:Y').json()
370+
expect(TypeOf).to.deep.eql({
371+
'@type': 'TypeOf',
372+
value: { '@type': 'Value', variable: 'X' },
373+
type: { '@type': 'NodeValue', variable: 'Y' }
374+
})
375+
});
376+
377+
it('check type_of(OBJ,Var)', () => {
378+
const TypeOf = WOQL.type_of(WOQL.string("X"), 'v:Y').json()
379+
expect(TypeOf).to.deep.eql({
380+
'@type': 'TypeOf',
381+
value: { '@type': 'Value', data: { '@type': 'xsd:string', '@value': 'X' } },
382+
type: { '@type': 'NodeValue', variable: 'Y' }
383+
})
384+
});
385+
367386
});

0 commit comments

Comments
 (0)