3

I made auto increment index:

box.space.metric:create_index('primary', {
        parts = {{'id', 'unsigned'}},
        sequence = true,
})

Then I try to pass nil in id field:

metric.id = nil

When I try insert this values, I catch error:

Tuple field 1 type does not match one required by operation: expected unsigned

What value do I have to pass for autoincrement field?

Second questions. If I use tarantool-cluster with few instances (for ex. cartridge-application based), is it prove use autoincrement indexes? Will there be a cases that there will be duplicate keys on different instances?

vk26
  • 345
  • 3
  • 9

1 Answers1

6

It is not possible to pass nil. When you assign nil, you erase field. Use box.NULL instead. But better, use some kind of cluster id, which perform well across cluster, instead of autoincrement, which works only inside one node.

For cluster-wide ids I could propose UUID or something like ULID (for ex from https://github.com/moonlibs/id)

Mons Anderson
  • 421
  • 2
  • 5