Skip to content

Commit

Permalink
Fix comparisons with languages failing
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbeeke committed Mar 1, 2023
1 parent f5c4bbd commit 202e51d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/sparqlee/lib/functions/RegularFunctions.ts
Expand Up @@ -94,6 +94,11 @@ const equality = {
overloads: declare(C.RegularOperator.EQUAL)
.numberTest(() => (left, right) => left === right)
.stringTest(() => (left, right) => left.localeCompare(right) === 0)
.set(
[ TypeURL.RDF_LANG_STRING, TypeURL.RDF_LANG_STRING ],
() => ([ left, right ]: E.LangStringLiteral[]) => bool(left.str() === right.str() &&
left.language === right.language),
)
.booleanTest(() => (left, right) => left === right)
.dateTimeTest(() => (left, right) => left.getTime() === right.getTime())
.set(
Expand All @@ -107,7 +112,7 @@ function RDFTermEqual(_left: Term, _right: Term): boolean {
const left = _left.toRDF();
const right = _right.toRDF();
const val = left.equals(right);
if ((left.termType === 'Literal') && (right.termType === 'Literal')) {
if (!val && (left.termType === 'Literal') && (right.termType === 'Literal')) {
throw new Err.RDFEqualTypeError([ _left, _right ]);
}
return val;
Expand Down
Expand Up @@ -58,10 +58,14 @@ describe('evaluation of \'=\'', () => {
runTestTable({
...config,
testTable: `
"test1"@en "test1"@en = true
"test1" "test1" = true
empty empty = true
empty aaa = false
aaa aaa = true
aaa bbb = false
"test1" "test2" = false
"test1"@en "test2"@en = false
`,
});
});
Expand Down

0 comments on commit 202e51d

Please sign in to comment.