diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java index afd1cdf13b6d..0fec1e3c5eb2 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java @@ -14072,10 +14072,12 @@ public List getBlockConditionsByConditionTypeAndValue(String String conditionTypeUpper = conditionType != null ? conditionType.toUpperCase() : null; selectPreparedStatement.setString(1, conditionTypeUpper); selectPreparedStatement.setString(2, conditionTypeUpper); - selectPreparedStatement.setString(3, conditionValue); if (isExactMatch) { + selectPreparedStatement.setString(3, conditionValue); selectPreparedStatement.setString(4, tenantDomain); } else { + String conditionValuePattern = "%" + conditionValue + "%"; + selectPreparedStatement.setString(3, conditionValuePattern); selectPreparedStatement.setString(4, conditionValue); selectPreparedStatement.setString(5, tenantDomain); } diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java index a0b3cb641d3d..f9166711a6fc 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java @@ -3393,7 +3393,7 @@ public static class ThrottleSQLConstants{ + "BLOCK_CONDITION = ? AND DOMAIN = ? "; public static final String GET_BLOCK_CONDITIONS_BY_TYPE_AND_VALUE_SQL = "SELECT CONDITION_ID, TYPE, BLOCK_CONDITION, ENABLED, DOMAIN, UUID FROM AM_BLOCK_CONDITIONS WHERE " - + "(TYPE = ? OR ? IS NULL) AND (BLOCK_CONDITION LIKE CONCAT('%', ?, '%') OR ? IS NULL) AND DOMAIN = ?"; + + "(TYPE = ? OR ? IS NULL) AND (BLOCK_CONDITION LIKE ? OR ? IS NULL) AND DOMAIN = ?"; public static final String GET_BLOCK_CONDITIONS_BY_TYPE_AND_EXACT_VALUE_SQL = "SELECT CONDITION_ID, TYPE, BLOCK_CONDITION, ENABLED, DOMAIN, UUID FROM AM_BLOCK_CONDITIONS WHERE " + "(TYPE = ? OR ? IS NULL) AND (BLOCK_CONDITION = ?) AND DOMAIN = ?";