summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2015-10-28 17:41:44 +0100
committerAndras Timar <andras.timar@collabora.com>2015-11-05 22:02:48 +0100
commit3458c7844b3ed8fcb3dcc92dc31ce66d2fc498e3 (patch)
treec714f6130e3f8826ff31b53bd706f83ca9bba27a
parent99f256296fc8121eb02422e58bd0718f1ccbe397 (diff)
base new query wizard: fix confusion between display name and field name
Change-Id: I75354ffea2daede55b34e4cf3321d57196be3d9b Reviewed-on: https://gerrit.libreoffice.org/19652 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit c7a520868ecf6d5de48dc3964a7bccab3fa480c3)
-rw-r--r--wizards/com/sun/star/wizards/db/SQLQueryComposer.java26
-rw-r--r--wizards/com/sun/star/wizards/ui/FilterComponent.java4
2 files changed, 24 insertions, 6 deletions
diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
index 0a30846ae1c0..c9c9400de10e 100644
--- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
+++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
@@ -77,7 +77,7 @@ public class SQLQueryComposer
int iAggregate = CurDBMetaData.getAggregateIndex(CurDBMetaData.FieldColumns[i].getDisplayFieldName());
if (iAggregate > -1)
{
- sSelectClause += CurDBMetaData.AggregateFieldNames[iAggregate][1] + "(" + getComposedAliasFieldName(CurDBMetaData.AggregateFieldNames[iAggregate][0]) + ")";
+ sSelectClause += CurDBMetaData.AggregateFieldNames[iAggregate][1] + "(" + getComposedAliasDisplayName(CurDBMetaData.AggregateFieldNames[iAggregate][0]) + ")";
if (_baddAliasFieldNames)
{
sSelectClause += getAliasFieldNameClause(CurDBMetaData.AggregateFieldNames[iAggregate][0]);
@@ -85,7 +85,7 @@ public class SQLQueryComposer
}
else
{
- sSelectClause += getComposedAliasFieldName(CurDBMetaData.FieldColumns[i].getDisplayFieldName());
+ sSelectClause += getComposedAliasDisplayName(CurDBMetaData.FieldColumns[i].getDisplayFieldName());
if (_baddAliasFieldNames)
{
sSelectClause += getAliasFieldNameClause(CurDBMetaData.FieldColumns[i].getDisplayFieldName());
@@ -182,7 +182,7 @@ public class SQLQueryComposer
{
sOrder += ", ";
}
- sOrder += CurDBMetaData.AggregateFieldNames[iAggregate][1] + "(" + getComposedAliasFieldName(CurDBMetaData.AggregateFieldNames[iAggregate][0]) + ")";
+ sOrder += CurDBMetaData.AggregateFieldNames[iAggregate][1] + "(" + getComposedAliasDisplayName(CurDBMetaData.AggregateFieldNames[iAggregate][0]) + ")";
sOrder += " " + CurDBMetaData.getSortFieldNames()[i][1];
m_queryComposer.setOrder(sOrder);
}
@@ -311,7 +311,7 @@ public class SQLQueryComposer
}
}
- private String getComposedAliasFieldName(String _fieldname)
+ private String getComposedAliasDisplayName(String _fieldname)
{
FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByDisplayName(_fieldname);
final String curCommandName = CurFieldColumn.getCommandName();
@@ -329,6 +329,24 @@ public class SQLQueryComposer
return quoteName(curAliasName) + "." + quoteName(curFieldName);
}
+ private String getComposedAliasFieldName(String _fieldname)
+ {
+ FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByFieldName(_fieldname);
+ final String curCommandName = CurFieldColumn.getCommandName();
+ final String curFieldName = CurFieldColumn.getFieldName();
+ CommandName curComposedCommandName = getComposedCommandByDisplayName(curCommandName);
+ if (curComposedCommandName == null)
+ {
+ //return _fieldname;
+ if ( curCommandName.length() > 0 )
+ return quoteName(curCommandName) + "." + quoteName(curFieldName);
+ else
+ return quoteName(curFieldName);
+ }
+ String curAliasName = curComposedCommandName.getAliasName();
+ return quoteName(curAliasName) + "." + quoteName(curFieldName);
+ }
+
private CommandName getComposedCommandByAliasName(String _AliasName)
{
if (composedCommandNames != null)
diff --git a/wizards/com/sun/star/wizards/ui/FilterComponent.java b/wizards/com/sun/star/wizards/ui/FilterComponent.java
index ab6fa7a506cc..38af3bc0f802 100644
--- a/wizards/com/sun/star/wizards/ui/FilterComponent.java
+++ b/wizards/com/sun/star/wizards/ui/FilterComponent.java
@@ -119,7 +119,7 @@ public class FilterComponent
String sControlNameSuffix = sIncSuffix + "_" + getIndexNumber(sControlName);
XListBox xCurFieldListBox = UnoRuntime.queryInterface(XListBox.class, CurUnoDialog.xDlgContainer.getControl(sControlName));
String CurDisplayFieldName = xCurFieldListBox.getSelectedItem();
- FieldColumn CurFieldColumn = new FieldColumn(oQueryMetaData, CurDisplayFieldName);
+ FieldColumn CurFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(CurDisplayFieldName);
String sControlNameTextValue = "txtValue" + sControlNameSuffix;
XControl xValueControl = CurUnoDialog.xDlgContainer.getControl(sControlNameTextValue);
@@ -303,7 +303,7 @@ public class FilterComponent
String FieldName;
if (_CurDBMetaData != null)
{
- FieldColumn CurDBFieldColumn = _CurDBMetaData.getFieldColumnByDisplayName(_filtercondition.Name);
+ FieldColumn CurDBFieldColumn = _CurDBMetaData.getFieldColumnByFieldName(_filtercondition.Name);
FieldName = CurDBFieldColumn.getFieldTitle();
}
else