Comparing array with number in GT always returns true

,

Function GT takes any value as a type.
The bug is when one compares Array with Number.
Fauna always returns true.

GT([1],0)

true

>> Time elapsed: 77ms

GT([1],1)

true

>> Time elapsed: 227ms

GT([1],2)

true

opposite is for LT it always returns false

LT([1],2)

false

>> Time elapsed: 7ms

LT([1],1)

false

>> Time elapsed: 9ms

LT([1],0)

false

I’m not sure why GT/LT allows to compare different types of values. Should it abort then?

Hi @ambrt,

Thanks for reporting! Let me investigate a bit.

Luigi

1 Like

Hi @ambrt,

LT() and GT() allow you to compare different data types, but are compared using the type precedence.

Types have an order of precedence. When comparing values of different types, they are ranked in the following order, from least to greatest.
    1   Number (integers and decimals: 0.5 < 1 < 1.5 < 2)
    2   Byte
    3   String
    4   Array (ordered lexically, like strings)
    5   Object (ordered lexically, like strings)
    6   Ref
    7   Timestamp
    8   Date
    9   Boolean (false < true)
    10  Null
null > Date > String > Number

Luigi

@Luigi_Servini, thank you for reply, i haven’t seen that part of doc - its not a priority but maybe docs for GT etc could be updated to point to this precedence.