提交 ac464e4b 编写于 作者: S Serge Rider

#15735 Attribute binding fix

上级 9bc3a812
......@@ -721,20 +721,24 @@ public class DBExecUtils {
// Fix of #11194. If column name and alias are equals we could try to get real column name
// from parsed query because driver doesn't return it.
String columnName = attrMeta.getName();
if (updateColumnMeta &&
CommonUtils.equalObjects(columnName, attrMeta.getLabel()) &&
sqlQuery != null &&
attrMeta.getOrdinalPosition() < sqlQuery.getSelectItemCount())
if (sqlQuery != null &&
updateColumnMeta &&
CommonUtils.equalObjects(columnName, attrMeta.getLabel()))
{
SQLSelectItem selectItem = sqlQuery.getSelectItem(attrMeta.getOrdinalPosition());
if (selectItem.isPlainColumn()) {
String realColumnName = selectItem.getName();
if (!CommonUtils.equalObjects(realColumnName, columnName)) {
if (DBUtils.isQuotedIdentifier(dataSource, realColumnName)) {
columnName = DBUtils.getUnQuotedIdentifier(dataSource, realColumnName);
} else {
// #12008
columnName = DBObjectNameCaseTransformer.transformName(dataSource, realColumnName);
int asteriskIndex = sqlQuery.getSelectItemAsteriskIndex();
if ((asteriskIndex < 0 || asteriskIndex > attrMeta.getOrdinalPosition()) &&
attrMeta.getOrdinalPosition() < sqlQuery.getSelectItemCount())
{
SQLSelectItem selectItem = sqlQuery.getSelectItem(attrMeta.getOrdinalPosition());
if (selectItem.isPlainColumn()) {
String realColumnName = selectItem.getName();
if (!CommonUtils.equalObjects(realColumnName, columnName)) {
if (DBUtils.isQuotedIdentifier(dataSource, realColumnName)) {
columnName = DBUtils.getUnQuotedIdentifier(dataSource, realColumnName);
} else {
// #12008
columnName = DBObjectNameCaseTransformer.transformName(dataSource, realColumnName);
}
}
}
}
......
......@@ -283,6 +283,18 @@ public class SQLQuery implements SQLScriptElement {
return selectItems == null || selectItems.size() <= index ? null : selectItems.get(index);
}
public int getSelectItemAsteriskIndex() {
if (selectItems != null) {
for (int i = 0; i < selectItems.size(); i++) {
SQLSelectItem item = selectItems.get(i);
if (item.getName().contains("*")) {
return i;
}
}
}
return -1;
}
@NotNull
public String getOriginalText() {
return originalText;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册