Skip to content
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

Tuple:frommap() or insert_map() #3282

Closed
sharonovd opened this issue Mar 26, 2018 · 5 comments
Closed

Tuple:frommap() or insert_map() #3282

sharonovd opened this issue Mar 26, 2018 · 5 comments
Assignees
Labels
app feature A new functionality lua
Milestone

Comments

@sharonovd
Copy link

Please consider adding built-in tuple:frommap() functionality.
That would be useful for transparent managing formatted spaces via REST API

Possible examples (originally proposed by @Igorjan94):

tarantool> t = {subscriber_status_id = 42, subscriber_id = 1, phone = '79160000000', contract_id = 1}
---
...

tarantool> subscriber:fromMap(t)
---
- [1, 1, '79160000000', 42]
...

tarantool> subscriber:insert(t)
---
- [1, 1, '79160000000', 42]
...```

@sharonovd
Copy link
Author

Regarding inserts - please also consider case when primary id is autogenerated (e g via sequence), and thus not provided by inserter

@kyukhin kyukhin added this to the 1.10.1 milestone Mar 27, 2018
kshcherbatov added a commit that referenced this issue Mar 28, 2018
kshcherbatov added a commit that referenced this issue Mar 28, 2018
kshcherbatov added a commit that referenced this issue Mar 29, 2018
kshcherbatov added a commit that referenced this issue Apr 2, 2018
kshcherbatov added a commit that referenced this issue Apr 2, 2018
kshcherbatov added a commit that referenced this issue Apr 2, 2018
This feature is designed to build tuple or table object by map.
Tuple output is default. If you wish to make a table, specify table = true option.
subscriber:frommap({ddd = 1, aaa = 2, ccc = 3, bbb = 4}, {table = true})

Closes #3282
kshcherbatov added a commit that referenced this issue Apr 4, 2018
This feature is designed to build tuple or table object by map.
Tuple output is default. If you wish to make a table, specify table = true option.
subscriber:frommap({ddd = 1, aaa = 2, ccc = 3, bbb = 4}, {table = true})

Closes #3282
kshcherbatov added a commit that referenced this issue Apr 4, 2018
This feature is designed to build tuple or table object by map.
Tuple output is default. If you wish to make a table, specify table = true option.
subscriber:frommap({ddd = 1, aaa = 2, ccc = 3, bbb = 4}, {table = true})

Closes #3282
kshcherbatov added a commit that referenced this issue Apr 4, 2018
This feature is designed to build tuple or table object by map.
Tuple output is default. If you wish to make a table, specify table = true option.
subscriber:frommap({ddd = 1, aaa = 2, ccc = 3, bbb = 4}, {table = true})

Closes #3282
kshcherbatov added a commit that referenced this issue Apr 9, 2018
This feature is designed to build tuple or table object by map.
Tuple output is default. If you wish to make a table, specify table = true option.
subscriber:frommap({ddd = 1, aaa = 2, ccc = 3, bbb = 4}, {table = true})

Closes #3282
@Gerold103
Copy link
Collaborator

@TarantoolBot documen

@TarantoolBot
Copy link
Collaborator

@Gerold103: Invalid request type.

@Gerold103
Copy link
Collaborator

@TarantoolBot document
Title: document new space method in Lua: frommap()
Space:frommap() allows to generate a well-formatted tuple ready to insert into the space from a Lua dictionary with pairs field_name = field_value.
For example:

format = {}
format[1] = {name = 'field1', type = 'unsigned'}
format[2] = {name = 'field2', type = 'unsigned'}
s = box.schema.create_space('test', {format = format})
pk = s:create_index('pk')
t = s:frommap({field1 = 100, field2 = 200})
s:insert(t)

By default, it returns a tuple as cdata, but you can pass the option: frommap(tuple, {table = true}), and then the result will be a Lua tale.

@TarantoolBot
Copy link
Collaborator

@Gerold103: Accept.

@tarantool tarantool deleted a comment from TarantoolBot Apr 9, 2018
kshcherbatov added a commit that referenced this issue Apr 9, 2018
This feature is designed to build tuple or table object by map.
Tuple output is default. If you wish to make a table, specify table = true option.
subscriber:frommap({ddd = 1, aaa = 2, ccc = 3, bbb = 4}, {table = true})

Closes #3282
kshcherbatov added a commit that referenced this issue Apr 9, 2018
This feature is designed to build tuple or table object by map.
Tuple output is default. If you wish to make a table, specify table = true option.
subscriber:frommap({ddd = 1, aaa = 2, ccc = 3, bbb = 4}, {table = true})

Closes #3282
kshcherbatov added a commit that referenced this issue Apr 9, 2018
This feature is designed to build tuple or table object by map.
Tuple output is default. If you wish to make a table, specify table = true option.
subscriber:frommap({ddd = 1, aaa = 2, ccc = 3, bbb = 4}, {table = true})

Closes #3282
@Gerold103 Gerold103 removed their assignment Apr 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app feature A new functionality lua
Projects
None yet
Development

No branches or pull requests

6 participants