Skip to content

Commit 5d994f8

Browse files
authored
Extend cleanObject() to handle booleans
WOQLQuery.prototype.cleanObject is supposed to transform values (e.g. strings and numbers) into the appropriate json-ld form. So far, this did not cover booleans. This proposal allows to write ```js WOQL.triple('v:doc', 'scm:myBooleanProperty', false) ``` instead of the more cumbersome ```js WOQL.triple('v:doc', 'scm:myBooleanProperty', { '@type': 'xsd:boolean', '@value': true }) ``` see this [discord discussion](https://discord.com/channels/689805612053168129/689886415491825703/869867176583118918) for more context
1 parent 1d4991c commit 5d994f8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/query/woqlCore.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ WOQLQuery.prototype.cleanObject = function(o, t) {
308308
} else if (typeof o == 'object' && o) {
309309
if (o['@value']) obj['woql:datatype'] = o
310310
else return o
311+
} else if (typeof o == 'boolean') {
312+
t = t || 'xsd:boolean'
313+
obj['woql:datatype'] = this.jlt(o, t)
311314
}
312315
return obj
313316
}

0 commit comments

Comments
 (0)