[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - dbaccess/source
Lionel Elie Mamane
lionel at mamane.lu
Tue Apr 10 15:22:40 UTC 2018
dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 73 ++++++++++++++++-
dbaccess/source/core/inc/SingleSelectQueryComposer.hxx | 2
2 files changed, 73 insertions(+), 2 deletions(-)
New commits:
commit 060e43da66c759de2c4799131e13c5156f01d492
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/52576
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index 61859ffd1cca..17d4bd6806ee 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -1015,8 +1015,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))
@@ -1111,6 +1114,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 ef1d2df8903d..3ebd555b11d7 100644
--- a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
+++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
@@ -112,6 +112,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;
More information about the Libreoffice-commits
mailing list