Skip to content

Commit

Permalink
[#702] Fix invalid handling of discriminator predicate in collection …
Browse files Browse the repository at this point in the history
…update query generation
  • Loading branch information
Mobe91 authored and beikov committed Dec 19, 2018
1 parent 2ce6b63 commit 8b261d9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
Expand Up @@ -316,7 +316,6 @@ private <R> QuerySpecification getQuerySpecification(Query baseQuery, Query exam
returningAttributeBindingMap,
getUpdateExampleQuery(),
updateSql,
discriminatorPredicate,
setExpressionContainingUpdateQueries,
columnOnlyRemappings,
columnExpressionRemappings
Expand All @@ -337,7 +336,6 @@ private <R> QuerySpecification getQuerySpecification(Query baseQuery, Query exam
returningAttributeBindingMap,
getUpdateExampleQuery(),
updateSql,
discriminatorPredicate,
setExpressionContainingUpdateQueries,
columnOnlyRemappings,
columnExpressionRemappings,
Expand Down
Expand Up @@ -39,17 +39,15 @@ public class CollectionUpdateModificationQuerySpecification<T> extends Modificat

private final Query updateExampleQuery;
private final String updateSql;
private final String discriminatorPredicate;
private final List<Query> setExpressionContainingUpdateQueries;
private final Map<String, String> columnOnlyRemappings;
private final Map<String, String> columnExpressionRemappings;

public CollectionUpdateModificationQuerySpecification(AbstractCommonQueryBuilder<?, ?, ?, ?, ?> commonQueryBuilder, Query baseQuery, Query exampleQuery, Set<Parameter<?>> parameters, Set<String> parameterListNames, boolean recursive, List<CTENode> ctes, boolean shouldRenderCteNodes, boolean isEmbedded, String[] returningColumns,
Map<DbmsModificationState, String> includedModificationStates, Map<String, String> returningAttributeBindingMap, Query updateExampleQuery, String updateSql, String discriminatorPredicate, List<Query> setExpressionContainingUpdateQueries, Map<String, String> columnOnlyRemappings, Map<String, String> columnExpressionRemappings) {
Map<DbmsModificationState, String> includedModificationStates, Map<String, String> returningAttributeBindingMap, Query updateExampleQuery, String updateSql, List<Query> setExpressionContainingUpdateQueries, Map<String, String> columnOnlyRemappings, Map<String, String> columnExpressionRemappings) {
super(commonQueryBuilder, baseQuery, exampleQuery, parameters, parameterListNames, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap);
this.updateExampleQuery = updateExampleQuery;
this.updateSql = updateSql;
this.discriminatorPredicate = discriminatorPredicate;
this.setExpressionContainingUpdateQueries = setExpressionContainingUpdateQueries;
this.columnOnlyRemappings = columnOnlyRemappings;
this.columnExpressionRemappings = columnExpressionRemappings;
Expand All @@ -70,7 +68,7 @@ protected void initialize() {
for (Query updateQuery : setExpressionContainingUpdateQueries) {
participatingQueries.add(updateQuery);
String setExpressionSql = extendedQuerySupport.getSql(em, updateQuery);
int assignIndex = SqlUtils.indexOfWhere(setExpressionSql) + " where ".length() + discriminatorPredicate.length();
int assignIndex = SqlUtils.indexOfWhere(setExpressionSql) + " where ".length();
// TODO: fix this for row values/embeddables which might have parenthesis around or use OR
int columnOnlyRemappingStartIndex = setClauseSqlSb.length();
int columnOnlyRemappingEndIndex = columnOnlyRemappingStartIndex + (setExpressionSql.indexOf('=', assignIndex) - assignIndex);
Expand Down
Expand Up @@ -40,9 +40,9 @@ public class ReturningCollectionUpdateModificationQuerySpecification<T> extends
private final ReturningObjectBuilder<T> objectBuilder;

public ReturningCollectionUpdateModificationQuerySpecification(AbstractCommonQueryBuilder<?, ?, ?, ?, ?> commonQueryBuilder, Query baseQuery, Query exampleQuery, Set<Parameter<?>> parameters, Set<String> parameterListNames, boolean recursive, List<CTENode> ctes, boolean shouldRenderCteNodes,
boolean isEmbedded, String[] returningColumns, Map<DbmsModificationState, String> includedModificationStates, Map<String, String> returningAttributeBindingMap, Query updateExampleQuery, String updateSql, String discriminatorPredicate, List<Query> setExpressionContainingUpdateQueries,
boolean isEmbedded, String[] returningColumns, Map<DbmsModificationState, String> includedModificationStates, Map<String, String> returningAttributeBindingMap, Query updateExampleQuery, String updateSql, List<Query> setExpressionContainingUpdateQueries,
Map<String, String> columnOnlyRemappings, Map<String, String> columnExpressionRemappings, ReturningObjectBuilder<T> objectBuilder) {
super(commonQueryBuilder, baseQuery, exampleQuery, parameters, parameterListNames, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap, updateExampleQuery, updateSql, discriminatorPredicate, setExpressionContainingUpdateQueries, columnOnlyRemappings, columnExpressionRemappings);
super(commonQueryBuilder, baseQuery, exampleQuery, parameters, parameterListNames, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap, updateExampleQuery, updateSql, setExpressionContainingUpdateQueries, columnOnlyRemappings, columnExpressionRemappings);
this.objectBuilder = objectBuilder;
}

Expand Down

0 comments on commit 8b261d9

Please sign in to comment.