Skip to content

Interval comparison is weird #7659

Open
@DifferentialOrange

Description

@DifferentialOrange

Bug description

Datetime interval type comparison yield counter-intuitive results.

  • OS: Linux
  • OS Version: Ubuntu 20.04
  • Architecture: amd64

Tarantool 2.10.1-0-g482d91c66

Steps to reproduce

tarantool> datetime.interval.new{hour=1} == datetime.interval.new{hour=1}
---
- true
...

tarantool> datetime.interval.new{hour=1} == datetime.interval.new{min=60}
---
- false
...

tarantool> datetime.interval.new{hour=1} > datetime.interval.new{min=60}
---
- true
...

tarantool> datetime.interval.new{hour=1} < datetime.interval.new{min=60}
---
- false
...

tarantool> datetime.interval.new{hour=1} < datetime.interval.new{min=61}
---
- false
...

Expected behavior

Simple approach to == comparison is rather understandable, but >, <, >=, <= is really confusing. @ImeevMA said that intervals are not designed to be comparable by nature, so maybe it's worth to forbid using compare operators in Lua.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdatetime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions