Skip to content

Commit

Permalink
#36415 Fix grouping panel usage when column of composite type with ne…
Browse files Browse the repository at this point in the history
…sted composite type is filtered
  • Loading branch information
E1izabeth committed Dec 13, 2024
1 parent f84ffc8 commit 86cd497
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public String prepareSqlString(@Nullable String subqueryAlias) {
this.getDataSource(),
subqueryAlias,
new DBDAttributeConstraint(this.binding),
subqueryAlias != null,
subqueryAlias != null
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ public String generateGroupingQuery(String queryText) throws DBException {

SQLDialect sqlDialect = dataSource.getSQLDialect();
if (select.getFromItem() instanceof Table table) {
select.setFromItem(new FormattedTable(table, sqlDialect));
FormattedTable formattedTable = new FormattedTable(table, sqlDialect);
// implicitly parsed where-conditions might have use table alias if presented,
// so don't forget it while replacing the table reference
formattedTable.setAlias(table.getAlias());
select.setFromItem(formattedTable);
}

List<SelectItem> selectItems = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void appendConditionString(
// TODO: Would be nice to have some asserts here

var names = constraints.stream()
.map(constraint -> getConstraintAttributeName(dataSource, conditionTable, constraint, subQuery))
.map(constraint -> getConstraintAttributeName(dataSource, conditionTable, constraint, subQuery, true))
.toList();

var values = constraints.stream()
Expand Down Expand Up @@ -140,7 +140,7 @@ public void appendConditionString(
query.append('(');
}

String attrName = getConstraintAttributeName(dataSource, conditionTable, constraint, subQuery);
String attrName = getConstraintAttributeName(dataSource, conditionTable, constraint, subQuery, true);
if (constraint.getAttribute() != null) {
attrName = dataSource.getSQLDialect().getTypeCastClause(constraint.getAttribute(), attrName, true);
}
Expand Down Expand Up @@ -440,7 +440,8 @@ public static String getConstraintAttributeName(
@NotNull DBPDataSource dataSource,
@Nullable String conditionTable,
@NotNull DBDAttributeConstraint constraint,
boolean subQuery
boolean subQuery,
boolean includeContainerName
) {
// Attribute name could be an expression. So check if this is a real attribute
// and generate full/quoted name for it.
Expand All @@ -451,7 +452,7 @@ public static String getConstraintAttributeName(
binding.getEntityAttribute().getName().equals(binding.getMetaAttribute().getName()) ||
binding instanceof DBDAttributeBindingType) {
if (binding.getEntityAttribute() instanceof DBSContextBoundAttribute entityAttribute) {
return entityAttribute.formatMemberReference(true, conditionTable, DBPAttributeReferencePurpose.DATA_SELECTION);
return entityAttribute.formatMemberReference(includeContainerName, conditionTable, DBPAttributeReferencePurpose.DATA_SELECTION);

Check warning on line 455 in plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/sql/StandardSQLDialectQueryGenerator.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Report

plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/sql/StandardSQLDialectQueryGenerator.java#L455

Line is longer than 140 characters (found 148).
} else {
return DBUtils.getObjectFullName(
dataSource,
Expand Down

0 comments on commit 86cd497

Please sign in to comment.