Skip to content

update operations on decimal fields. #871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TarantoolBot opened this issue Aug 22, 2019 · 3 comments
Closed

update operations on decimal fields. #871

TarantoolBot opened this issue Aug 22, 2019 · 3 comments
Assignees
Labels
feature A new functionality reference [location] Tarantool manual, Reference part server [area] Task relates to Tarantool's server (core) functionality

Comments

@TarantoolBot
Copy link
Collaborator

tuple:update and space:update now support deicmal operands for
arithmetic operations ('+' and '-'). The syntax is as usual:

d = box.tuple.new(decimal.new('1'))
---
...
d:update{{'+', 1, decimal.new('0.5')}}
---
- [1.5]
...

Insertion ('!') and assignment ('=') are also supported:

a = decimal.new('1')
---
...
b = decimal.new('1e10')
---
...
c = decimal.new('1e-10')
---
...
d = box.tuple.new{5, a, 6, b, 7, c, "string"}
---
...
d
---
- [5, 1, 6, 10000000000, 7, 0.0000000001, 'string']
...

d:update{{'!', 3, dec.new('1234.5678')}}
---
- [5, 1, 1234.5678, 6, 10000000000, 7, 0.0000000001, 'string']
...
d:update{{'=', -1, dec.new('0.12345678910111213')}}
---
- [5, 1, 6, 10000000000, 7, 0.0000000001, 0.12345678910111213]

When performing an arithmetic operation ('+', '-'), where either the
updated field or the operand is decimal, the result will be decimal.

When both the updated field and the operand are decimal, the result
will, of course, be decimal.

...

Requested by @sergepetrenko in tarantool/tarantool@8317189.

@lenkis lenkis added 2.2 feature A new functionality reference [location] Tarantool manual, Reference part server [area] Task relates to Tarantool's server (core) functionality labels Aug 22, 2019
@pgulutzan pgulutzan added the need feedback [special status] On hold, awaiting feedback label Aug 27, 2019
@pgulutzan
Copy link
Contributor

Should this be for the version 2.3 manual?

@sergepetrenko
Copy link
Contributor

@pgulutzan yep

@sergepetrenko sergepetrenko removed the need feedback [special status] On hold, awaiting feedback label Sep 9, 2019
@pgulutzan pgulutzan added 2.3 and removed 2.2 labels Sep 11, 2019
@pgulutzan
Copy link
Contributor

This didn't involve significant change, since the description of update didn't exclude decimal. I merely mentioned that decimal was one example of a numeric field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new functionality reference [location] Tarantool manual, Reference part server [area] Task relates to Tarantool's server (core) functionality
Projects
None yet
Development

No branches or pull requests

4 participants