summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connectivity/source/parse/sqlnode.cxx5
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignView.cxx15
-rw-r--r--include/connectivity/sqlparse.hxx5
3 files changed, 21 insertions, 4 deletions
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index 1e003cb68d46..ede688b4e2fd 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -1157,7 +1157,8 @@ OUString OSQLParser::stringToDouble(const OUString& _rValue,sal_Int16 _nScale)
OSQLParseNode* OSQLParser::predicateTree(OUString& rErrorMessage, const OUString& rStatement,
const Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter,
- const Reference< XPropertySet > & xField)
+ const Reference< XPropertySet > & xField,
+ bool bUseRealName)
{
// Guard the parsing
::osl::MutexGuard aGuard(getMutex());
@@ -1181,7 +1182,7 @@ OSQLParseNode* OSQLParser::predicateTree(OUString& rErrorMessage, const OUString
// #75243# use the RealName of the column if there is any otherwise the name which could be the alias
// of the field
Reference< XPropertySetInfo> xInfo = m_xField->getPropertySetInfo();
- if ( xInfo->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME)))
+ if ( bUseRealName && xInfo->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME)))
m_xField->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME)) >>= aString;
else
m_xField->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aString;
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<OQueryController&>(getController()).getNumberFormatter(),
- _rxColumn);
+ _rxColumn,
+ false);
return pParseNode;
}
diff --git a/include/connectivity/sqlparse.hxx b/include/connectivity/sqlparse.hxx
index f6a7b0f4043b..78888998f7f7 100644
--- a/include/connectivity/sqlparse.hxx
+++ b/include/connectivity/sqlparse.hxx
@@ -191,9 +191,12 @@ namespace connectivity
bool bInternational = false);
// Check a Predicate
+ // set bUseRealName to false if you pass a xField that comes from where you got that field,
+ // as opposed from to from yourself.
OSQLParseNode* predicateTree(OUString& rErrorMessage, const OUString& rStatement,
const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter,
- const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xField);
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xField,
+ bool bUseRealName = true);
// Access to the context
const IParseContext& getContext() const {return *m_pContext;}