tarantool / cartridge-springdata

Spring Data Tarantool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No exception is thrown if entity fields do not match the space format

ArtDu opened this issue · comments

Example to reproduce:

local simple_object_with_linked_list = box.schema.space.create(
            'simple_object_with_linked_list',
            {
                format = {
                    { name = 'id', type = 'unsigned' },
                    { name = 'list', type = 'any' },
                    { name = 'bucket_id', type = 'unsigned' },
                },
                if_not_exists = true,
            }
    )
@Tuple
public class SimpleObjectWithLinkedList {
    LinkedList<String> list;
}

And we get the problem here:

@Override
public Optional<TarantoolField> getField(String fieldName) {
    int fieldPosition = getFieldPositionByName(fieldName);
    if (fieldPosition < 0) {
        fieldPosition = Integer.MAX_VALUE;
    }

    return getField(fieldPosition);
}

@Override
public Optional<TarantoolField> getField(int fieldPosition) {
    Assert.state(fieldPosition >= 0, "Field position starts with 0");

    if (fieldPosition < fields.size()) {
        return Optional.ofNullable(fields.get(fieldPosition));
    }
    return Optional.empty();
}

We take the position of the field by metadata, but the real positions and count in TarantoolTuple are different.

For the example above, we get an empty entity. I do not know how critical this bug is, but there is a place to be.