Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.openhab.core.items.GenericItem;
import org.openhab.core.items.Item;
import org.openhab.core.persistence.FilterCriteria;
import org.openhab.core.persistence.FilterCriteria.Operator;
import org.openhab.core.persistence.FilterCriteria.Ordering;

import software.amazon.awssdk.enhanced.dynamodb.AttributeConverter;
Expand Down Expand Up @@ -144,7 +145,7 @@ private static void addStateFilter(QueryEnhancedRequest.Builder queryBuilder,
if (filter.getState() != null) {
// Convert filter's state to DynamoDBItem in order get suitable string representation for the state
Expression.Builder stateFilterExpressionBuilder = Expression.builder()
.expression(String.format("#attr %s :value", filter.getOperator().getSymbol()));
.expression(String.format("#attr %s :value", operatorAsString(filter.getOperator())));
// Following will throw IllegalArgumentException when filter state is not compatible with
// item. This is acceptable.
GenericItem stateToFind = DynamoDBPersistenceService.copyItem(item, item, filter.getItemName(),
Expand Down Expand Up @@ -205,6 +206,19 @@ private static void addFilterbyItemAndTimeFilter(QueryEnhancedRequest.Builder qu
}
}

/**
* Convert op to string suitable for dynamodb filter expression
*
* @param op
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @param documentation is missing a description. It should be '@param op the operator to convert'.

Suggested change
* @param op
* @param op the operator to convert

Copilot uses AI. Check for mistakes.
* @return string representation corresponding to the given the Operator
*/
private static String operatorAsString(Operator op) {
if (op == Operator.NEQ) {
return "<>";
}
return op.getSymbol();
}

private static <T> void acceptAsDTO(Item item, boolean legacy, DynamoDBItemVisitor<T> visitor) {
ZonedDateTime dummyTimestamp = ZonedDateTime.now();
if (legacy) {
Expand Down
Loading