tarantool icon indicating copy to clipboard operation
tarantool copied to clipboard

datetime behaviour is not consistent with decimal and uuid

Open olegrok opened this issue 3 years ago • 5 comments

-- Can compare decimal with strings and numbers
tarantool> decimal.new(123) == '123'
---
- true
...

tarantool> decimal.new(123) == 123
---
- true
...
-- Can compare uuid with strings
tarantool> uuid.fromstr('744c5225-a962-40d2-a301-d401c43789eb') == '744c5225-a962-40d2-a301-d401c43789eb'
---
- true
...
--- Can't compare datetime with strings
tarantool> datetime.parse('2022-07-20T11:51:57.531005+0300') == '2022-07-20T11:51:57.531005+0300'
---
- false
...

olegrok avatar Jul 20 '22 08:07 olegrok

We did this on purpose. Won't fix

NeraverinTarantool avatar Feb 07 '23 16:02 NeraverinTarantool

We did this on purpose.

What is the purpose?

Totktonada avatar Feb 07 '23 16:02 Totktonada

Reopened to bring into attention.

Totktonada avatar Feb 08 '23 10:02 Totktonada

@Totktonada You can contact @Mons for details. The general meaning is that an implicit cast in this case (and in cases above) is worse than an explicit cast. Moreover, the more complex the type on which the implicit cast is performed, the higher the likelihood of encountering a problem.

NeraverinTarantool avatar Feb 08 '23 10:02 NeraverinTarantool

I understand your point, but things don't look very complex here. There is a strict ordering. If not (a < b) and not (b < a) than a == b.

Totktonada avatar Feb 08 '23 10:02 Totktonada