Skip to content

Commit f0e1051

Browse files
authored
feat(core): implement Role.NAME filter. (#14808)
1 parent 8c013c8 commit f0e1051

3 files changed

Lines changed: 38 additions & 1 deletion

File tree

core/src/main/java/io/kestra/core/models/QueryFilter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,12 @@ public List<Field> supportedField() {
359359
return List.of(Field.QUERY, Field.USERNAME, Field.GROUP, Field.NAME);
360360
}
361361
},
362+
ROLE {
363+
@Override
364+
public List<Field> supportedField() {
365+
return List.of(Field.QUERY, Field.NAME);
366+
}
367+
},
362368
SECRET_METADATA {
363369
@Override
364370
public List<Field> supportedField() {

core/src/test/java/io/kestra/core/models/QueryFilterTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ static Stream<Arguments> validOperationFilters() {
302302
Op.EQUALS,
303303
Op.IN
304304
)
305+
),
306+
307+
buildQueryFiltersForOperations(Field.NAME, Resource.ROLE,
308+
Set.of(
309+
Op.EQUALS
310+
)
305311
)
306312
).flatMap(s -> s);
307313
}
@@ -637,6 +643,23 @@ static Stream<Arguments> invalidOperationFilters() {
637643
Op.PREFIX,
638644
Op.NOT_EQUALS
639645
)
646+
),
647+
648+
buildQueryFiltersForOperations(Field.NAME, Resource.ROLE,
649+
Set.of(
650+
Op.GREATER_THAN,
651+
Op.LESS_THAN,
652+
Op.GREATER_THAN_OR_EQUAL_TO,
653+
Op.LESS_THAN_OR_EQUAL_TO,
654+
Op.CONTAINS,
655+
Op.NOT_IN,
656+
Op.STARTS_WITH,
657+
Op.ENDS_WITH,
658+
Op.REGEX,
659+
Op.PREFIX,
660+
Op.NOT_EQUALS,
661+
Op.IN
662+
)
640663
)
641664
).flatMap(s -> s);
642665
}

jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcRepository.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,14 @@ protected Condition getConditionOnField(
338338
return findMetadataCondition((Map<?, ?>) value, operation);
339339
}
340340

341+
return defaultHandlers(field, value, operation);
342+
}
343+
344+
private Condition defaultHandlers(
345+
QueryFilter.Field field,
346+
Object value,
347+
QueryFilter.Op operation
348+
) {
341349
// Convert the field name to lowercase and quote it
342350
Name columnName = getColumnName(field);
343351

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

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

425433
protected Condition statesFilter(List<State.Type> state) {

0 commit comments

Comments
 (0)