mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-19 18:05:41 -05:00
fix(repositories): unwanted integer to string conversion (#13586)
* fix(repositories): unwanted integer to string conversion * fix(repositories): clean code --------- Co-authored-by: nKwiatkowski <nkwiatkowski@kestra.io>
This commit is contained in:
@@ -329,8 +329,8 @@ public abstract class AbstractJdbcRepository {
|
||||
|
||||
// Default handling for other fields
|
||||
return switch (operation) {
|
||||
case EQUALS -> DSL.field(columnName).eq(value.toString());
|
||||
case NOT_EQUALS -> DSL.field(columnName).ne(value.toString());
|
||||
case EQUALS -> DSL.field(columnName).eq(primitiveOrToString(value));
|
||||
case NOT_EQUALS -> DSL.field(columnName).ne(primitiveOrToString(value));
|
||||
case GREATER_THAN -> DSL.field(columnName).greaterThan(value);
|
||||
case LESS_THAN -> DSL.field(columnName).lessThan(value);
|
||||
case IN -> DSL.field(columnName).in(ListUtils.convertToListString(value));
|
||||
@@ -346,6 +346,24 @@ public abstract class AbstractJdbcRepository {
|
||||
};
|
||||
}
|
||||
|
||||
private static Object primitiveOrToString(Object o) {
|
||||
if (o == null) return null;
|
||||
|
||||
if (o instanceof Boolean
|
||||
|| o instanceof Byte
|
||||
|| o instanceof Short
|
||||
|| o instanceof Integer
|
||||
|| o instanceof Long
|
||||
|| o instanceof Float
|
||||
|| o instanceof Double
|
||||
|| o instanceof Character
|
||||
|| o instanceof String) {
|
||||
return o;
|
||||
}
|
||||
|
||||
return o.toString();
|
||||
}
|
||||
|
||||
protected Name getColumnName(QueryFilter.Field field){
|
||||
return DSL.quotedName(field.name().toLowerCase());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user