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

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

Open
ArtDu opened this issue Mar 2, 2022 · 0 comments
Open
Labels
bug Something isn't working

Comments

@ArtDu
Copy link
Contributor

ArtDu commented Mar 2, 2022

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.

@dkasimovskiy dkasimovskiy added the bug Something isn't working label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants