Skip to content

Commit

Permalink
update version and fix filter return type
Browse files Browse the repository at this point in the history
  • Loading branch information
Knerio committed Dec 5, 2024
1 parent 771cd3a commit 73485e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "eu.koboo"
version = "1.2.6"
version = "1.2.7"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -108,10 +109,15 @@ private Object executeMethod(IndexedMethod<E, ID, R> indexedMethod, Object[] arg
case FILTER:
findIterable = repositoryMeta.createIterable(Filters.and((Bson) arguments[arguments.length - 1], filter), methodName);

if (Collection.class.isAssignableFrom(method.getReturnType())) {
Long methodDefinedEntityCount = indexedMethod.getMethodDefinedEntityCount();
if (methodDefinedEntityCount == -1 || methodDefinedEntityCount > 1) {
if (methodDefinedEntityCount != -1) {
findIterable = findIterable.limit(Math.toIntExact(methodDefinedEntityCount));
}
return findIterable.into(new ArrayList<>());
} else {
return findIterable.first();
}
return findIterable.first();
case FIND:
findIterable = repositoryMeta.createIterable(filter, methodName);
findIterable = repositoryMeta.applySortObject(method, findIterable, arguments);
Expand All @@ -121,7 +127,7 @@ private Object executeMethod(IndexedMethod<E, ID, R> indexedMethod, Object[] arg
// Many = -1 / unlimited
// Top = specific count
// First = 1 / first entity
Long methodDefinedEntityCount = indexedMethod.getMethodDefinedEntityCount();
methodDefinedEntityCount = indexedMethod.getMethodDefinedEntityCount();
if (methodDefinedEntityCount == -1 || methodDefinedEntityCount > 1) {
if (methodDefinedEntityCount != -1) {
findIterable = findIterable.limit(Math.toIntExact(methodDefinedEntityCount));
Expand Down

0 comments on commit 73485e5

Please sign in to comment.