Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions core/src/main/java/io/kestra/core/models/QueryFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ public List<Field> supportedField() {
return List.of(Field.QUERY, Field.USERNAME, Field.GROUP, Field.NAME);
}
},
ROLE {
@Override
public List<Field> supportedField() {
return List.of(Field.QUERY, Field.NAME);
}
},
SECRET_METADATA {
@Override
public List<Field> supportedField() {
Expand Down
23 changes: 23 additions & 0 deletions core/src/test/java/io/kestra/core/models/QueryFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ static Stream<Arguments> validOperationFilters() {
Op.EQUALS,
Op.IN
)
),

buildQueryFiltersForOperations(Field.NAME, Resource.ROLE,
Set.of(
Op.EQUALS
)
)
).flatMap(s -> s);
}
Expand Down Expand Up @@ -637,6 +643,23 @@ static Stream<Arguments> invalidOperationFilters() {
Op.PREFIX,
Op.NOT_EQUALS
)
),

buildQueryFiltersForOperations(Field.NAME, Resource.ROLE,
Set.of(
Op.GREATER_THAN,
Op.LESS_THAN,
Op.GREATER_THAN_OR_EQUAL_TO,
Op.LESS_THAN_OR_EQUAL_TO,
Op.CONTAINS,
Op.NOT_IN,
Op.STARTS_WITH,
Op.ENDS_WITH,
Op.REGEX,
Op.PREFIX,
Op.NOT_EQUALS,
Op.IN
)
)
).flatMap(s -> s);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,14 @@ protected Condition getConditionOnField(
return findMetadataCondition((Map<?, ?>) value, operation);
}

return defaultHandlers(field, value, operation);
}

private Condition defaultHandlers(
QueryFilter.Field field,
Object value,
QueryFilter.Op operation
) {
// Convert the field name to lowercase and quote it
Name columnName = getColumnName(field);

Expand Down Expand Up @@ -419,7 +427,7 @@ protected Condition groupCondition(Object value, QueryFilter.Op operation) {
}

protected Condition nameCondition(Object value, QueryFilter.Op operation) {
throw new InvalidQueryFiltersException("Unsupported operation: " + operation);
return defaultHandlers(QueryFilter.Field.NAME, value, operation);
}

protected Condition statesFilter(List<State.Type> state) {
Expand Down
Loading