tarantool / tarantool/tarantool

Interval comparison is weird

Open
#7,659 3 comments 0 reactions 1 assignee View on GitHub

@Mons is already working on this.

Since Sep 8, 2022.

bug datetime
Dominant language
Lua
Stars
3.7k
Forks
419
Avg merge
1d 23h
Merged PRs (30d)
88

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.