cqframework / cql-engine

Clinical Quality Language Evaluation Engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type is not comparable error when attempting to sort a list containing null

brynrhodes opened this issue · comments

When evaluating this expression:

define X: ({ 1, 2, 3, null }) A sort asc

the engine throws an error "Type is not comparable", but this should evaluate.

Looking at the spec for the appropriate behavior, section 2.3.3, last paragraph says the nulls should appear at the beginning of the list when it is sorted ascending, and at the end of the list when it is sorted descending.

I also noticed a related bug manifesting in the CQL Runner:

define X: ({ 1, 2, 3, null }) A sort asc
define Y: ({ null, 1, 2, 3 }) A sort asc
define Z: ({ 1, 2, null, 3 }) A sort asc

When the null is the first item in the list like with Y, the "Type is not comparable" message doesn't display at all, whereas when the null is in the middle or the end, like in X or Z, it does display.

Resolved in release 1.2.20