Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
[BZ 1080909] DynaGroup expression evaluator is not strict when groupi…
Browse files Browse the repository at this point in the history
…ng by

resource configuration property

Dynagroup expressions using  pluginConfiguration[prop] or
resourceConfiguratoin[prop] will now be matched 'strict' to property name.
Strict match in means resulting SQL would be 'simple.name = :argX' instead
of original 'simple.name LIKE :argX'.
  • Loading branch information
Libor Zoubek committed Apr 4, 2014
1 parent 78cf972 commit 21bb0b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private String[][] getSuccessTestCases() {
"SELECT res.id FROM Resource res " + //
" JOIN res.pluginConfiguration pluginConf, PropertySimple simple, PropertyDefinition simpleDef " + //
" JOIN res.resourceType.pluginConfigurationDefinition pluginConfDef " + //
" WHERE simple.name LIKE :arg1 ESCAPE '" + escapeChar + "'" + //
" WHERE simple.name = :arg1 " + //
" AND simple.stringValue = :arg2 " + //
" AND simple.configuration = pluginConf " + //
" AND simpleDef.configurationDefinition = pluginConfDef " + //
Expand All @@ -81,7 +81,7 @@ private String[][] getSuccessTestCases() {
"SELECT res.id FROM Resource res " + //
" JOIN res.resourceConfiguration conf, PropertySimple simple, PropertyDefinition simpleDef " + //
" JOIN res.resourceType.resourceConfigurationDefinition confDef " + //
" WHERE simple.name LIKE :arg1 ESCAPE '" + escapeChar + "'" + //
" WHERE simple.name = :arg1 " + //
" AND simple.stringValue LIKE :arg2 ESCAPE '" + escapeChar + "'" + //
" AND simple.configuration = conf " + //
" AND simpleDef.configurationDefinition = confDef " + //
Expand All @@ -103,7 +103,7 @@ private String[][] getSuccessTestCases() {
" SELECT simple.stringValue FROM Resource res " + //
" JOIN res.resourceConfiguration conf, PropertySimple simple, PropertyDefinition simpleDef " + //
" JOIN res.resourceType.resourceConfigurationDefinition confDef " + //
" WHERE simple.name LIKE :arg1 ESCAPE '" + escapeChar + "'" + //
" WHERE simple.name = :arg1 " + //
" AND simple.configuration = conf " + //
" AND simpleDef.configurationDefinition = confDef " + //
" AND simple.name = simpleDef.name AND simpleDef.type != 'PASSWORD' " + //
Expand All @@ -112,7 +112,7 @@ private String[][] getSuccessTestCases() {
" SELECT res.id FROM Resource res " + //
" JOIN res.resourceConfiguration conf, PropertySimple simple, PropertyDefinition simpleDef " + //
" JOIN res.resourceType.resourceConfigurationDefinition confDef " + //
" WHERE simple.name LIKE :arg1 ESCAPE '" + escapeChar + "'" + //
" WHERE simple.name = :arg1 " + //
" AND simple.stringValue = :arg2 " + //
" AND simple.configuration = conf " + //
" AND simpleDef.configurationDefinition = confDef " + //
Expand Down Expand Up @@ -150,7 +150,7 @@ private String[][] getSuccessTestCases() {
"SELECT res.id FROM Resource res " + //
" JOIN res.pluginConfiguration pluginConf, PropertySimple simple, PropertyDefinition simpleDef " + //
" JOIN res.resourceType.pluginConfigurationDefinition pluginConfDef " + //
" WHERE simple.name LIKE :arg1 ESCAPE '" + escapeChar + "'" + //
" WHERE simple.name = :arg1 " + //
" AND simple.stringValue IS NULL " + //
" AND simple.configuration = pluginConf " + //
" AND simpleDef.configurationDefinition = pluginConfDef " + //
Expand Down Expand Up @@ -811,6 +811,16 @@ public String[] getExpressions() {
});
}

@Test(expectedExceptions = InvalidExpressionException.class, expectedExceptionsMessageRegExp = "Unrecognized.*")
public void doNotAllowEmptyProperty() throws Exception {
evaluateExpressions(new ExpressionGenerator() {
@Override
public String[] getExpressions() {
return new String[] { "resource.greatGreatGrandParent.resourceConfiguration[] = 1" };
}
});
}

private String cleanUp(String result) {
return result.replaceAll("\\s+", " ").trim();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ private void parseExpression(String expression) throws InvalidExpressionExceptio
addJoinCondition(joinCondition);
addJoinCondition(definitionJoinCondition);

populatePredicateCollections(PROP_SIMPLE_ALIAS + ".name", "%" + propertyName + "%", false, false);
populatePredicateCollections(PROP_SIMPLE_ALIAS + ".name", propertyName, false, false);
populatePredicateCollections(PROP_SIMPLE_ALIAS + ".stringValue", value);

whereStatics.add(PROP_SIMPLE_ALIAS + ".configuration = " + joinCondition.alias);
Expand Down

0 comments on commit 21bb0b2

Please sign in to comment.