tarantool / cartridge-springdata

Spring Data Tarantool
Other
18 stars 7 forks source link

Throws an error if @Tuple is not present in the repository when the @Query annotated method is used and return is Tuple(number indexed table) #69

Closed ArtDu closed 2 years ago

ArtDu commented 2 years ago

It is hard to find the error, as there may be strange behavior, for example, returning empty value for a tuple or NPE

vrogach2020 commented 2 years ago

It's a working case. But we have to improve error reporting - if the result returned from lua function is not null, but no fields in entity match the metadata or metadata is null.

andrei-punko commented 2 years ago

In similar case we resolved the issue by using same @Tuple not only for entity class but for related repository class too. Not sure is it right way

ArtDu commented 2 years ago

It's strange that the SimpleTarantoolRepository functions work when the wrong space name is specified in @Tuple. But when using the @Query function where the return will be the same as findAll(from SimpleTarantoolRepository) - crud.select - there will be the same number of tuples, but the object fields will be NULL.

vrogach2020 commented 2 years ago

when the wrong space name is specified in @Tuple

I think we should throw exception in this case

wey1and commented 2 years ago

We need to analyze the cases of working with methods in the repository. We need to understand which cases are working and which are not. For example: default methods, like save and find that return a map or a tuple, etc.

ArtDu commented 2 years ago

If we consider only those cases where we exactly forgot to indicate @Tuple, so far I see one case where exactly throwing Exceptions needs to be done

  1. When we forgot to specify @Tuple, but our return type is tuple (number indexed table) - then cartridge-java converts the response to an ArrayList and passes it on for conversion to cartridge-springdata. We can check if ArrayList arrived to mapToEntity and then raise specific error, because we only accept Map or TarantoolTuple or PrimitiveType.