From 6a330f8ae8639e13391b1129a6428b9602e989a4 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Wed, 28 Jan 2015 18:24:40 +0100 Subject: Query Design: use correct name for columns that come from another query. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I25b4ccdc2f50ba89687e1f4c871f286251a28e21 Reviewed-on: https://gerrit.libreoffice.org/14344 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara (cherry picked from commit 97b11a21b64f4bac5af67819549f6e384d61c086) --- dbaccess/source/ui/querydesign/QueryDesignView.cxx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'dbaccess') diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 33bab8fe526e..880cafcb74e9 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -3080,10 +3080,23 @@ OSQLParseNode* OQueryDesignView::getPredicateTreeFromEntry(OTableFieldDescRef pE } OUString sTest(_sCriteria); + // _rxColumn, if it is a "lookup" column, not a computed column, + // is guaranteed to be the column taken from the *source* of the column, + // that is either a table or another query. + // _rxColumn is *not* taken from the columns of the query we are constructing + // (and rightfully so, since it may not be part of these columns; SELECT A FROM t WHERE B = foo) + // If it is a computed column, we just constructed it above, with same Name and RealName. + // In all cases, we should use the "external" name of the column, not the "RealName"; + // the latter is the name that the column had in the source of the source query. + // An example: we are designing "SELECT A, B FROM q WHERE C='foo'" + // q itself is query "SELECT aye AS A, bee as B, cee as C FROM t" + // We are currently treating the entry "C='foo'" + // Then _rxColumn has Name "C" and RealName "cee". We should *obviously* use "C", not "cee". OSQLParseNode* pParseNode = rParser.predicateTree( _rsErrorMessage, sTest, static_cast(getController()).getNumberFormatter(), - _rxColumn); + _rxColumn, + false); return pParseNode; } -- cgit