Handling the empty object set for where clause in new actions (#8017)
This commit is contained in:
parent
713ed76676
commit
d8dec82565
|
|
@ -2,6 +2,8 @@ package com.appsmith.external.models;
|
|||
|
||||
import com.appsmith.external.constants.ConditionalOperator;
|
||||
import com.appsmith.external.constants.DataType;
|
||||
import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginError;
|
||||
import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginException;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
|
@ -12,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.appsmith.external.helpers.DataTypeStringUtils.stringToKnownDataTypeConverter;
|
||||
|
|
@ -66,6 +69,12 @@ public class Condition {
|
|||
|
||||
for(Object config : configurationList) {
|
||||
Map<String, String> condition = (Map<String, String>) config;
|
||||
if (condition.entrySet().isEmpty()) {
|
||||
// Its an empty object set by the client for UX. Ignore the same
|
||||
continue;
|
||||
} else if (!condition.keySet().containsAll(Set.of("path", "operator", "value"))) {
|
||||
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Filtering Condition not configured properly");
|
||||
}
|
||||
conditionList.add(new Condition(
|
||||
condition.get("path"),
|
||||
condition.get("operator"),
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import lombok.ToString;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
|
@ -41,8 +42,9 @@ public class MethodConfig {
|
|||
|
||||
public MethodConfig(List<Property> propertyList) {
|
||||
propertyList.stream().parallel().forEach(property -> {
|
||||
if (property.getValue() != null) {
|
||||
String propertyValue = String.valueOf(property.getValue());
|
||||
Object value = property.getValue();
|
||||
if (value != null) {
|
||||
String propertyValue = String.valueOf(value);
|
||||
switch (property.getKey()) {
|
||||
case "sheetUrl":
|
||||
this.spreadsheetUrl = propertyValue;
|
||||
|
|
@ -89,8 +91,15 @@ public class MethodConfig {
|
|||
this.rowObjects = propertyValue;
|
||||
break;
|
||||
case "where":
|
||||
if (property.getValue() != null && !((List<Object>) property.getValue()).isEmpty()) {
|
||||
this.whereConditions = Condition.generateFromConfiguration((List<Object>) property.getValue());
|
||||
if (value != null && value instanceof List) {
|
||||
// Check if all values in the where condition are null.
|
||||
boolean allValuesNull = ((List) value).stream()
|
||||
.allMatch(valueMap -> valueMap == null ||
|
||||
((Map) valueMap).entrySet().stream().allMatch(e -> ((Map.Entry) e).getValue() == null));
|
||||
|
||||
if (!allValuesNull) {
|
||||
this.whereConditions = Condition.generateFromConfiguration((List<Object>) value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user