[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - connectivity/source dbaccess/source include/connectivity

Lionel Elie Mamane lionel at mamane.lu
Thu Feb 12 02:09:47 PST 2015


 connectivity/source/parse/sqlnode.cxx              |    5 +++--
 dbaccess/source/ui/querydesign/QueryDesignView.cxx |   15 ++++++++++++++-
 include/connectivity/sqlparse.hxx                  |    5 ++++-
 3 files changed, 21 insertions(+), 4 deletions(-)

New commits:
commit 97b11a21b64f4bac5af67819549f6e384d61c086
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Jan 28 18:24:40 2015 +0100

    Query Design: use correct name for columns that come from another query.
    
    Change-Id: I25b4ccdc2f50ba89687e1f4c871f286251a28e21
    Reviewed-on: https://gerrit.libreoffice.org/14344
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index 1e003cb..ede688b 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 33bab8f..880cafc 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 f6a7b0f..7888899 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;}


More information about the Libreoffice-commits mailing list