cartridge-springdata icon indicating copy to clipboard operation
cartridge-springdata copied to clipboard

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

Open ArtDu opened this issue 3 years ago • 0 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

ArtDu avatar Jan 11 '22 19:01 ArtDu