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

Lionel Elie Mamane lionel at mamane.lu
Sun Apr 8 15:05:59 UTC 2018


 dbaccess/source/core/api/SingleSelectQueryComposer.cxx |   74 ++++++++++++++++-
 dbaccess/source/core/inc/SingleSelectQueryComposer.hxx |    2 
 2 files changed, 73 insertions(+), 3 deletions(-)

New commits:
commit e29435932d84076c4d9c443e6f6fd95a08799386
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Apr 8 08:14:52 2018 +0200

    tdf#116772 adapt handling of LIKE conditions to cleaned up StructuredFilter
    
    Change-Id: Ifc60da9a95833ee7820a0e03354fa1a8c006e136
    Reviewed-on: https://gerrit.libreoffice.org/52573
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>

diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index f35ee41c1f44..e7a7af6870e9 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -1003,8 +1003,11 @@ bool OSingleSelectQueryComposer::setANDCriteria( OSQLParseNode const * pConditio
     {
         return setComparsionPredicate(pCondition,_rIterator,rFilter,xFormatter);
     }
-    else if (SQL_ISRULE(pCondition,like_predicate) ||
-             SQL_ISRULE(pCondition,test_for_null) ||
+    else if (SQL_ISRULE(pCondition,like_predicate))
+    {
+        return setLikePredicate(pCondition,_rIterator,rFilter,xFormatter);
+    }
+    else if (SQL_ISRULE(pCondition,test_for_null) ||
              SQL_ISRULE(pCondition,in_predicate) ||
              SQL_ISRULE(pCondition,all_or_any_predicate) ||
              SQL_ISRULE(pCondition,between_predicate))
@@ -1099,6 +1102,72 @@ sal_Int32 OSingleSelectQueryComposer::getPredicateType(OSQLParseNode const * _pP
     return nPredicate;
 }
 
+bool OSingleSelectQueryComposer::setLikePredicate(OSQLParseNode const * pCondition, OSQLParseTreeIterator const & _rIterator,
+                                            std::vector < PropertyValue >& rFilter, const Reference< css::util::XNumberFormatter > & xFormatter) const
+{
+    OSL_ENSURE(SQL_ISRULE(pCondition, like_predicate),"setLikePredicate: pCondition is not a LikePredicate");
+
+    assert(pCondition->count() == 2);
+    OSQLParseNode const *pRowValue = pCondition->getChild(0);
+    OSQLParseNode const *pPart2 = pCondition->getChild(1);
+
+    PropertyValue aItem;
+    if ( SQL_ISTOKEN(pPart2->getChild(0),NOT) )
+        aItem.Handle = SQLFilterOperator::NOT_LIKE;
+    else
+        aItem.Handle = SQLFilterOperator::LIKE;
+
+    if (SQL_ISRULE(pRowValue, column_ref))
+    {
+        OUString aValue;
+
+        // skip (optional "NOT") and "LIKE"
+        for (size_t i=2; i < pPart2->count(); i++)
+        {
+            pPart2->getChild(i)->parseNodeToPredicateStr(
+                aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>(m_sDecimalSep.toChar() ) );
+        }
+
+        aItem.Name = getColumnName(pRowValue,_rIterator);
+        aItem.Value <<= aValue;
+        rFilter.push_back(aItem);
+    }
+    else if (SQL_ISRULE(pRowValue, set_fct_spec ) ||
+             SQL_ISRULE(pRowValue, general_set_fct))
+    {
+        OUString aValue;
+        OUString aColumnName;
+
+        pPart2->getChild(2)->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) );
+        pPart2->getChild(3)->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) );
+        pRowValue->parseNodeToPredicateStr( aColumnName, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep .toChar() ) );
+
+        aItem.Name = getColumnName(pRowValue,_rIterator);
+        aItem.Value <<= aValue;
+        rFilter.push_back(aItem);
+    }
+    else // Can only be an expression
+    {
+        OUString aName, aValue;
+
+        OSQLParseNode const *pValue = pPart2->getChild(2);
+
+        // Field names
+        for (size_t i=0;i< pRowValue->count();i++)
+             pRowValue->getChild(i)->parseNodeToPredicateStr( aName, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) );
+
+        // Criterion
+        for(size_t i=0;i< pValue->count();i++)
+            pValue->getChild(i)->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) );
+        pPart2->getChild(3)->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) );
+
+        aItem.Name = aName;
+        aItem.Value <<= aValue;
+        rFilter.push_back(aItem);
+    }
+    return true;
+}
+
 bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode const * pCondition, OSQLParseTreeIterator const & _rIterator,
                                             std::vector < PropertyValue >& rFilter, const Reference< css::util::XNumberFormatter > & xFormatter) const
 {
diff --git a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
index 524ca93cdcca..c349708ceded 100644
--- a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
+++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
@@ -114,6 +114,8 @@ namespace dbaccess
             std::vector< std::vector < css::beans::PropertyValue > >& rFilters, const css::uno::Reference< css::util::XNumberFormatter > & xFormatter) const;
         bool setANDCriteria(::connectivity::OSQLParseNode const * pCondition, ::connectivity::OSQLParseTreeIterator& _rIterator,
             std::vector < css::beans::PropertyValue > & rFilters, const css::uno::Reference< css::util::XNumberFormatter > & xFormatter) const;
+        bool setLikePredicate(::connectivity::OSQLParseNode const * pCondition, ::connectivity::OSQLParseTreeIterator const & _rIterator,
+            std::vector < css::beans::PropertyValue > & rFilters, const css::uno::Reference< css::util::XNumberFormatter > & xFormatter) const;
         bool setComparsionPredicate(::connectivity::OSQLParseNode const * pCondition, ::connectivity::OSQLParseTreeIterator const & _rIterator,
             std::vector < css::beans::PropertyValue > & rFilters, const css::uno::Reference< css::util::XNumberFormatter > & xFormatter) const;
 
commit ccc57c8f8fe6a910767f07b0f077fa76fb8db740
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Apr 8 08:15:31 2018 +0200

    this looks suspicious in light of cleaned up StructuredFilter
    
    Change-Id: I88f9834403e016e849dcd6c46638626b40252cf3
    Reviewed-on: https://gerrit.libreoffice.org/52574
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>

diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index 9f76150d75ca..f35ee41c1f44 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -1195,7 +1195,6 @@ bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode const * pC
 
         // Criterion
         aItem.Handle = getPredicateType(pCondition->getChild(1));
-        aValue       = pCondition->getChild(1)->getTokenValue();
         for(size_t i=0;i< pRhs->count();i++)
             pRhs->getChild(i)->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) );
 


More information about the Libreoffice-commits mailing list