You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Decimals may now be stored in spaces. A corresponding field type is
introduced: 'decimal'. Decimal values are also allowed in 'scalar',
'any' and 'number' fields.
'decimal' field type is appropriate for both memtx HASH and TREE
indices, as well as for vinyl TREE index.
Uniqueness is also preserved between decimals and other number types:
tarantool> box.space.test:insert{-0.92}
---
- error: Duplicate key exists in unique index 'pk' in space 'test'
...
tarantool> box.space.test:insert{decimal.new(-0.9)}
---
- error: Duplicate key exists in unique index 'pk' in space 'test'
...
You can also set decimal fields in space format:
tarantool> _ = box.schema.space.create('test')
---
...
tarantool> _ = box.space.test:create_index('pk')
---
...
tarantool> box.space.test:format{{name='id', type='unsigned'}, {name='balance', type='decimal'}}
---
...
tarantool> box.space.test:insert{1}
---
- error: Tuple field 2 required by space format is missing
...
tarantool> box.space.test:insert{1, 'string'}
---
- error: 'Tuple field 2 type does not match one required by operation: expected decimal'
...
tarantool> box.space.test:insert{1, 1.2345}
---
- error: 'Tuple field 2 type does not match one required by operation: expected decimal'
...
tarantool> box.space.test:insert{1, decimal.new('1337.420')}
---
- [1, 1337.420]
...
Decimals may now be stored in spaces. A corresponding field type is
introduced: 'decimal'. Decimal values are also allowed in 'scalar',
'any' and 'number' fields.
'decimal' field type is appropriate for both memtx HASH and TREE
indices, as well as for vinyl TREE index.
tarantool> box.space.test:create_index('pk', {parts={1, 'decimal'}})
parts:
is_nullable: false
fieldno: 1
id: 0
space_id: 512
type: TREE
name: pk
...
tarantool> for i = 1,10 do
> box.space.test:insert{decimal.new((i-5)/10)}
> end
...
Decimals may alse be inserted into
scalar
andnumber
fields. In thiscase all the number values are sorted correctly:
Uniqueness is also preserved between decimals and other number types:
You can also set decimal fields in space format:
Requested by @sergepetrenko in tarantool/tarantool@8ba7267.
The text was updated successfully, but these errors were encountered: