tarantool / cartridge-springdata

Spring Data Tarantool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't return one tuple/number indexed table without table wrapper

ArtDu opened this issue · comments

Right now we don't get to return a single array without additional wrapping.

@Test
    public void test_array_shouldCalledSuccessfully_byDomainType_withTuple() {
        //given
        SimpleArray expected = SimpleArray.builder()
                .testId(null)
                .testBoolean(true)
                .testString("abc")
                .testInteger(123)
                .testDouble(1.23)
                .build();

        //when
        SimpleArray actual = repositoryByDomainTypeWithTuple.getSimpleArray();

        //then
        assertEquals(expected, actual);
    }
public interface ArrayReturnRepositoryByDomainType extends TarantoolRepository<SimpleArray, Integer> {
    @Tuple("test_simple_object")
    @Query(function = "returning_simple_array")
    SimpleArray getSimpleArray();
}
function returning_simple_array()
    return { nil, true, "abc", 123, 1.23 }
end

We will get an error:

org.springframework.dao.InvalidDataAccessResourceUsageException: Failed to convert MessagePack value of type NIL to tuple; nested exception is io.tarantool.driver.exceptions.TarantoolTupleConversionException: Failed to convert MessagePack value of type NIL to tuple

But if you wrap it in an additional table, then everything is ok.

function returning_simple_array()
    return {{ nil, true, "abc", 123, 1.23 }}
end