[Libreoffice-commits] core.git: 2 commits - connectivity/source dbaccess/source include/connectivity

Lionel Elie Mamane lionel at mamane.lu
Wed Jan 28 09:35:32 PST 2015


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

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

    janitorial
    
    Change-Id: Ifb0a277a27613ea1a771a8bb3b8c784b9eca4f2f

diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index 3e5ab6a..1c8c3e6 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -1158,7 +1158,7 @@ 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< ::com::sun::star::util::XNumberFormatter > & xFormatter,
                                          const Reference< XPropertySet > & xField,
                                          bool bUseRealName)
 {
commit d613f6e00cbd315f21d49e58d18178f00bda83c5
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

diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index aaedf70..3e5ab6a 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -1159,7 +1159,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());
@@ -1183,7 +1184,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 be28408..8acc411 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -3079,10 +3079,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 8240be5..398e69f 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