Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect tuple equality behavior #1349

Open
brynrhodes opened this issue Mar 29, 2024 · 1 comment
Open

Incorrect tuple equality behavior #1349

brynrhodes opened this issue Mar 29, 2024 · 1 comment
Labels

Comments

@brynrhodes
Copy link
Member

This expression currently returns false:

define Test1: Tuple { Id : 1, Name : 'John' } = Tuple { Id : 2, Name : null }

But tuples have no implied ordering, so this should be null

Test cases for this (and other tuple equality testing) are being considered for the cql-tests repository here:
cqframework/cql-tests#3

When those tests are agreed and approved, they should be used as the source for the test for this issue

@JPercival
Copy link
Contributor

Are you certain this should be null? My reading of the spec here is that it would return false:

For tuple types, this means that equality returns true if and only if the tuples are of the same type, and the values for all elements that have values, by name, are equal.

No mention of "null". The discussion for Codes and Concepts says it uses "tuple semantics" and the example shown implies it would be false, not null.

The equal (=) operator for Codes and Concepts uses tuple equality semantics. This means that the operator will return true if and only if the values for each element by name are equal.

If either argument is null, or has different components specified, the result is null.

define "Code1": Code { system: 'http://loinc.org', code: '8480-6', version: '1.0', display: 'Systolic blood pressure' }
define "Concept1": Concept { codes: { Code1 }, display: 'Concepts' }
define "Concept2": Concept { codes: { Code1 }, display: 'More Concepts' }
define "EqualIsTrue": Code1 = Code1
define "EqualIsFalse": Concept1 = Concept2

Notice how Concept1 and Concept2 vary only by the value of display. In the example you posted the only difference is value of Name. I suppose Name may also vary by type, since it's System.Any in the latter.

@JPercival JPercival added the bug label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants