mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(dynamodb): apply filter expressions in Query (#123)
* fix(dynamodb): apply query filter expressions * fix(dynamodb): preserve query page state before filtering
This commit is contained in:
1 parent
d1d7ec3bd3
commit
8b6f4fa4f5
3 files changed
+147
-10
No files matched your search
@@ -486,16 +486,25 @@ public class DynamoDbService {
|
||||
}
|
||||
}
|
||||
|
||||
int scannedCount = results.size();
|
||||
List<JsonNode> evaluatedItems = results;
|
||||
JsonNode lastEvaluatedKey = null;
|
||||
|
||||
if (limit != null && limit > 0 && results.size() > limit) {
|
||||
JsonNode lastItem = results.get(limit - 1);
|
||||
if (limit != null && limit > 0 && evaluatedItems.size() > limit) {
|
||||
JsonNode lastItem = evaluatedItems.get(limit - 1);
|
||||
lastEvaluatedKey = buildKeyNode(table, lastItem, pkName, skName);
|
||||
results = results.subList(0, limit);
|
||||
evaluatedItems = new ArrayList<>(evaluatedItems.subList(0, limit));
|
||||
}
|
||||
|
||||
return new QueryResult(results, scannedCount, lastEvaluatedKey);
|
||||
int scannedCount = evaluatedItems.size();
|
||||
|
||||
if (filterExpression != null) {
|
||||
evaluatedItems = evaluatedItems.stream()
|
||||
.filter(item -> matchesFilterExpression(item, filterExpression,
|
||||
exprAttrNames, expressionAttrValues))
|
||||
.toList();
|
||||
}
|
||||
|
||||
return new QueryResult(evaluatedItems, scannedCount, lastEvaluatedKey);
|
||||
}
|
||||
|
||||
public ScanResult scan(String tableName, String filterExpression,
|
||||
|
||||
Reference in new issue
Block a user