connectivity/source/commontools/predicateinput.cxx | 2 connectivity/source/parse/sqlbison.y | 5 connectivity/source/parse/sqlnode.cxx | 247 +++++++++++------- connectivity/source/simpledbt/parsenode_s.cxx | 4 connectivity/source/simpledbt/parsenode_s.hxx | 1 dbaccess/source/ui/inc/QueryDesignView.hxx | 2 dbaccess/source/ui/querydesign/QueryDesignView.cxx | 5 dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx | 2 include/connectivity/sqlnode.hxx | 14 - include/connectivity/virtualdbtools.hxx | 1 svx/source/fmcomp/gridcell.cxx | 5 svx/source/form/filtnav.cxx | 2 svx/source/form/formcontroller.cxx | 1 13 files changed, 178 insertions(+), 113 deletions(-)
New commits: commit a0b720c9fca7ae7ad2a38637aa34b1a3a4bd9ef4 Author: Lionel Elie Mamane <[email protected]> Date: Fri Apr 26 16:45:54 2013 +0200 remove never-generated "predicate_check" entry Change-Id: Ib3957fbadf6bfebfaabd5bef09aaf7ab21862cd6 diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index f840039..0adc5f6 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1404,7 +1404,6 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: { OSQLParseNode::insert_statement, "insert_statement" }, { OSQLParseNode::insert_atom_commalist, "insert_atom_commalist" }, { OSQLParseNode::insert_atom, "insert_atom" }, - { OSQLParseNode::predicate_check, "predicate_check" }, { OSQLParseNode::from_clause, "from_clause" }, { OSQLParseNode::qualified_join, "qualified_join" }, { OSQLParseNode::cross_union, "cross_union" }, diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index fe27a41..d8007ac 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -3431,7 +3431,6 @@ void OQueryDesignView::fillFunctionInfo( const ::connectivity::OSQLParseNode* p case OSQLParseNode::between_predicate: case OSQLParseNode::like_predicate: case OSQLParseNode::test_for_null: - case OSQLParseNode::predicate_check: // Seems to never be generated? case OSQLParseNode::boolean_term: case OSQLParseNode::boolean_primary: case OSQLParseNode::in_predicate: diff --git a/include/connectivity/sqlnode.hxx b/include/connectivity/sqlnode.hxx index 3ab0b65..f0fe1ac 100644 --- a/include/connectivity/sqlnode.hxx +++ b/include/connectivity/sqlnode.hxx @@ -171,7 +171,6 @@ namespace connectivity insert_statement, insert_atom_commalist, insert_atom, - predicate_check, from_clause, qualified_join, cross_union, commit 16c9ce4877def18ca4578171a96615a632d08092 Author: Lionel Elie Mamane <[email protected]> Date: Fri Apr 26 16:44:43 2013 +0200 QueryDesign: in criteria, remove matching column_ref in simple expressions Basically, in first children of infix predicates in search_conditions Change-Id: I0e2f8fbdde023b088f33d2e2fcbd41110f0e02a8 diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 4c67ea3..f840039 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -129,6 +129,62 @@ namespace rNewValue += rQuot; return rNewValue; } + + bool columnMatchP(const connectivity::OSQLParseNode* pSubTree, const connectivity::SQLParseNodeParameter& rParam) + { + using namespace connectivity; + assert(SQL_ISRULE(pSubTree,column_ref)); + + // retrieve the field's name & table range + OUString aFieldName; + try + { + sal_Int32 nNamePropertyId = PROPERTY_ID_NAME; + if ( rParam.xField->getPropertySetInfo()->hasPropertyByName( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_REALNAME ) ) ) + nNamePropertyId = PROPERTY_ID_REALNAME; + rParam.xField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( nNamePropertyId ) ) >>= aFieldName; + } + catch ( Exception& ) + { + } + + if(pSubTree->count()) + { + const OSQLParseNode* pCol = pSubTree->getChild(pSubTree->count()-1); + if (SQL_ISRULE(pCol,column_val)) + { + assert(pCol->count() == 1); + pCol = pCol->getChild(0); + } + const OSQLParseNode* pTable(NULL); + switch (pSubTree->count()) + { + case 1: + break; + case 3: + pTable = pSubTree->getChild(0); + break; + case 5: + case 7: + SAL_WARN("connectivity.parse", "SQL: catalog and/or schema in column_ref in predicate"); + break; + default: + SAL_WARN("connectivity.parse", "columnMatchP: SQL grammar changed; column_ref has " << pSubTree->count() << " children"); + assert(false); + break; + } + // TODO: not all DBMS match column names case-insensitively... + // see XDatabaseMetaData::supportsMixedCaseIdentifiers() + // and XDatabaseMetaData::supportsMixedCaseQuotedIdentifiers() + if ( // table name matches (or no table name)? + ( !pTable || pTable->getTokenValue().equalsIgnoreAsciiCase(rParam.sPredicateTableAlias) ) + && // column name matches? + pCol->getTokenValue().equalsIgnoreAsciiCase(aFieldName) + ) + return true; + } + return false; + } } namespace connectivity @@ -342,7 +398,7 @@ namespace } //----------------------------------------------------------------------------- -void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const +void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const SQLParseNodeParameter& rParam, bool bSimple) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "[email protected]", "OSQLParseNode::impl_parseNodeToString_throw" ); if ( isToken() ) @@ -360,18 +416,19 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const // special handling for parameters case parameter: { + bSimple=false; if(!rString.isEmpty()) rString.appendAscii(" "); if (nCount == 1) // ? - m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam ); + m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam, false ); else if (nCount == 2) // :Name { - m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam ); + m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam, false ); rString.append(m_aChildren[1]->m_aNodeValue); } // [Name] else { - m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam ); + m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam, false ); rString.append(m_aChildren[1]->m_aNodeValue); rString.append(m_aChildren[2]->m_aNodeValue); } @@ -381,6 +438,7 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const // table refs case table_ref: + bSimple=false; if ( ( nCount == 2 ) || ( nCount == 3 ) || ( nCount == 5 ) ) { impl_parseTableRangeNodeToString_throw( rString, rParam ); @@ -390,16 +448,18 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const // table name - might be a query name case table_name: + bSimple=false; bHandled = impl_parseTableNameNodeToString_throw( rString, rParam ); break; case as_clause: + bSimple=false; assert(nCount == 0 || nCount == 2); if (nCount == 2) { if ( rParam.aMetaData.generateASBeforeCorrelationName() ) rString.append(OUString(" AS ")); - m_aChildren[1]->impl_parseNodeToString_throw( rString, rParam ); + m_aChildren[1]->impl_parseNodeToString_throw( rString, rParam, false ); } bHandled = true; break; @@ -413,7 +473,7 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const // Depending on whether international is given, LIKE is treated differently // international: *, ? are placeholders // else SQL92 conform: %, _ - impl_parseLikeNodeToString_throw( rString, rParam ); + impl_parseLikeNodeToString_throw( rString, rParam, bSimple ); bHandled = true; break; @@ -424,13 +484,14 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const case length_exp: case char_value_fct: { + bSimple=false; if (!addDateValue(rString, rParam)) { // Do not quote function name SQLParseNodeParameter aNewParam(rParam); aNewParam.bQuote = ( SQL_ISRULE(this,length_exp) || SQL_ISRULE(this,char_value_fct) ); - m_aChildren[0]->impl_parseNodeToString_throw( rString, aNewParam ); + m_aChildren[0]->impl_parseNodeToString_throw( rString, aNewParam, false ); aNewParam.bQuote = rParam.bQuote; //aNewParam.bPredicate = sal_False; // disable [ ] around names // look at i73215 OUStringBuffer aStringPara; @@ -439,7 +500,7 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const const OSQLParseNode * pSubTree = m_aChildren[i]; if (pSubTree) { - pSubTree->impl_parseNodeToString_throw( aStringPara, aNewParam ); + pSubTree->impl_parseNodeToString_throw( aStringPara, aNewParam, false ); // In the comma lists, put commas in-between all subtrees if ((m_eNodeType == SQL_NODE_COMMALISTRULE) && (i < (nCount - 1))) @@ -452,6 +513,15 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const } bHandled = true; } + case odbc_call_spec: + case subquery: + case term: + case factor: + case window_function: + case cast_spec: + case num_value_exp: + bSimple = false; + break; default: break; @@ -479,68 +549,16 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const // simplify criterion display by removing: // "currentFieldName" // "currentFieldName" = - // but only at the very beginning of the criterion - // (not embedded deep in the expression). - // TODO: replace "beginning of criterion" by "in simple expression", - // that is anything made of: + // but only in simple expressions. + // This means anything that is made of: + // (see the rules conditionalised by inPredicateCheck() in sqlbison.y). // - parentheses // - logical operators (and, or, not) // - comparison operators (IS, =, >, <, BETWEEN, LIKE, ...) - // (see where the parser calls inPredicateCheck for a full list) // but *not* e.g. in function arguments - if (rParam.bPredicate && rString.isEmpty() && rParam.xField.is() && SQL_ISRULE(pSubTree,column_ref)) + if (bSimple && rParam.bPredicate && rParam.xField.is() && SQL_ISRULE(pSubTree,column_ref)) { - bool bFilter = false; - // retrieve the field's name & table range - OUString aFieldName; - try - { - sal_Int32 nNamePropertyId = PROPERTY_ID_NAME; - if ( rParam.xField->getPropertySetInfo()->hasPropertyByName( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_REALNAME ) ) ) - nNamePropertyId = PROPERTY_ID_REALNAME; - rParam.xField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( nNamePropertyId ) ) >>= aFieldName; - } - catch ( Exception& ) - { - } - - if(pSubTree->count()) - { - const OSQLParseNode* pCol = pSubTree->m_aChildren[pSubTree->count()-1]; - if (SQL_ISRULE(pCol,column_val)) - { - assert(pCol->count() == 1); - pCol = pCol->getChild(0); - } - const OSQLParseNode* pTable(NULL); - switch (pSubTree->count()) - { - case 1: - break; - case 3: - pTable = pSubTree->m_aChildren[0]; - break; - case 5: - case 7: - SAL_WARN("connectivity.parse", "SQL: catalog and/or schema in column_ref in predicate"); - break; - default: - SAL_WARN("connectivity.parse", "impl_parseNodeToString_throw: SQL grammar changed; column_ref has " << pSubTree->count() << " children"); - assert(false); - break; - } - // TODO: not all DBMS match column names case-insensitively... - // see XDatabaseMetaData::supportsMixedCaseIdentifiers() - // and XDatabaseMetaData::supportsMixedCaseQuotedIdentifiers() - if ( // table name matches (or no table name)? - ( !pTable || pTable->getTokenValue().equalsIgnoreAsciiCase(rParam.sPredicateTableAlias) ) - && // column name matches? - pCol->getTokenValue().equalsIgnoreAsciiCase(aFieldName) - ) - bFilter = true; - } - - if (bFilter) + if (columnMatchP(pSubTree, rParam)) { // skip field ++i; @@ -558,7 +576,7 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const } else { - pSubTree->impl_parseNodeToString_throw( rString, aNewParam ); + pSubTree->impl_parseNodeToString_throw( rString, aNewParam, bSimple ); ++i; // In the comma lists, put commas in-between all subtrees @@ -568,7 +586,7 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const } else { - pSubTree->impl_parseNodeToString_throw( rString, aNewParam ); + pSubTree->impl_parseNodeToString_throw( rString, aNewParam, bSimple ); ++i; // In the comma lists, put commas in-between all subtrees @@ -580,6 +598,36 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const rString.appendAscii(","); } } + // The right hand-side of these operators is not simple + switch ( getKnownRuleID() ) + { + case general_set_fct: + case set_fct_spec: + case position_exp: + case extract_exp: + case length_exp: + case char_value_fct: + case odbc_call_spec: + case subquery: + case comparison_predicate: + case between_predicate: + case like_predicate: + case test_for_null: + case in_predicate: + case existence_test: + case unique_test: + case all_or_any_predicate: + case join_condition: + case boolean_test: + case comparison_predicate_part_2: + case parenthesized_boolean_value_expression: + case other_like_predicate_part_2: + case between_predicate_part_2: + bSimple=false; + break; + default: + break; + } } } } @@ -644,7 +692,7 @@ bool OSQLParseNode::impl_parseTableNameNodeToString_throw( OUStringBuffer& rStri { // parse the sub-select to SDBC level, too OUStringBuffer sSubSelect; - pSubQueryNode->impl_parseNodeToString_throw( sSubSelect, rParam ); + pSubQueryNode->impl_parseNodeToString_throw( sSubSelect, rParam, false ); if ( !sSubSelect.isEmpty() ) sCommand = sSubSelect.makeStringAndClear(); } @@ -690,11 +738,11 @@ void OSQLParseNode::impl_parseTableRangeNodeToString_throw(OUStringBuffer& rStri // rString += OUString(" "); ::std::for_each(m_aChildren.begin(),m_aChildren.end(), - boost::bind( &OSQLParseNode::impl_parseNodeToString_throw, _1, boost::ref( rString ), boost::cref( rParam ) )); + boost::bind( &OSQLParseNode::impl_parseNodeToString_throw, _1, boost::ref( rString ), boost::cref( rParam ), false )); } //----------------------------------------------------------------------------- -void OSQLParseNode::impl_parseLikeNodeToString_throw( OUStringBuffer& rString, const SQLParseNodeParameter& rParam ) const +void OSQLParseNode::impl_parseLikeNodeToString_throw( OUStringBuffer& rString, const SQLParseNodeParameter& rParam, bool bSimple ) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "[email protected]", "OSQLParseNode::impl_parseLikeNodeToString_throw" ); OSL_ENSURE(count() == 2,"count != 2: Prepare for GPF"); @@ -705,38 +753,12 @@ void OSQLParseNode::impl_parseLikeNodeToString_throw( OUStringBuffer& rString, c SQLParseNodeParameter aNewParam(rParam); //aNewParam.bQuote = sal_True; // why setting this to true? @see http://www.openoffice.org/issues/show_bug.cgi?id=75557 - // if there is a field given we don't display the fieldname, if there are any - sal_Bool bAddName = sal_True; - if (rParam.xField.is()) - { - // retrieve the fields name - OUString aFieldName; - try - { - // retrieve the fields name - OUString aString; - rParam.xField->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aString; - aFieldName = aString.getStr(); - } - catch ( Exception& ) - { - OSL_FAIL( "OSQLParseNode::impl_parseLikeNodeToString_throw Exception occurred!" ); - } - if ( !m_aChildren[0]->isLeaf() ) - { - const OSQLParseNode* pCol = m_aChildren[0]->getChild(m_aChildren[0]->count()-1); - if ((SQL_ISRULE(pCol,column_val) && pCol->getChild(0)->getTokenValue().equalsIgnoreAsciiCase(aFieldName)) || - pCol->getTokenValue().equalsIgnoreAsciiCase(aFieldName) ) - bAddName = sal_False; - } - } - - if (bAddName) - m_aChildren[0]->impl_parseNodeToString_throw( rString, aNewParam ); + if (bSimple && !columnMatchP(m_aChildren[0], rParam)) + m_aChildren[0]->impl_parseNodeToString_throw( rString, aNewParam, bSimple ); const OSQLParseNode* pPart2 = m_aChildren[1]; - pPart2->getChild(0)->impl_parseNodeToString_throw( rString, aNewParam ); - pPart2->getChild(1)->impl_parseNodeToString_throw( rString, aNewParam ); + pPart2->getChild(0)->impl_parseNodeToString_throw( rString, aNewParam, false ); + pPart2->getChild(1)->impl_parseNodeToString_throw( rString, aNewParam, false ); pParaNode = pPart2->getChild(2); pEscNode = pPart2->getChild(3); @@ -747,9 +769,9 @@ void OSQLParseNode::impl_parseLikeNodeToString_throw( OUStringBuffer& rString, c rString.append(SetQuotation(aStr,OUString("\'"),OUString("\'\'"))); } else - pParaNode->impl_parseNodeToString_throw( rString, aNewParam ); + pParaNode->impl_parseNodeToString_throw( rString, aNewParam, false ); - pEscNode->impl_parseNodeToString_throw( rString, aNewParam ); + pEscNode->impl_parseNodeToString_throw( rString, aNewParam, false ); } @@ -1441,7 +1463,8 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: { OSQLParseNode::character_string_type, "character_string_type" }, { OSQLParseNode::other_like_predicate_part_2, "other_like_predicate_part_2" }, { OSQLParseNode::between_predicate_part_2, "between_predicate_part_2" }, - { OSQLParseNode::cast_spec, "cast_spec" } + { OSQLParseNode::cast_spec, "cast_spec" }, + { OSQLParseNode::window_function, "window_function" } }; const size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( aRuleDescriptions[0] ); // added a new rule? Adjust this map! diff --git a/include/connectivity/sqlnode.hxx b/include/connectivity/sqlnode.hxx index 51a9ec2..3ab0b65 100644 --- a/include/connectivity/sqlnode.hxx +++ b/include/connectivity/sqlnode.hxx @@ -231,6 +231,7 @@ namespace connectivity other_like_predicate_part_2, between_predicate_part_2, cast_spec, + window_function, rule_count // last value }; @@ -423,8 +424,8 @@ namespace connectivity bool _bSubstitute) const; private: - void impl_parseNodeToString_throw( OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const; - void impl_parseLikeNodeToString_throw( OUStringBuffer& rString, const SQLParseNodeParameter& rParam ) const; + void impl_parseNodeToString_throw( OUStringBuffer& rString, const SQLParseNodeParameter& rParam, bool bSimple=true ) const; + void impl_parseLikeNodeToString_throw( OUStringBuffer& rString, const SQLParseNodeParameter& rParam, bool bSimple=true ) const; void impl_parseTableRangeNodeToString_throw( OUStringBuffer& rString, const SQLParseNodeParameter& rParam ) const; /** parses a table_name node into a SQL statement particle. commit fccfa69c15a1f55dda753b84d4f6919145b6f3f3 Author: Lionel Elie Mamane <[email protected]> Date: Fri Apr 26 16:36:28 2013 +0200 remove unused const Change-Id: I94c274e8afc70fa702063d61139299a7bde9165b diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 6d6c4f6..c2b02ce 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -4467,11 +4467,6 @@ const Locale& OParseContext::getDefaultLocale() // sofort nach dem Scanner-Aufruf in eine gleichnamige eigene // Member-Variable. -const double fMilliSecondsPerDay = 86400000.0; - -//------------------------------------------------------------------------------ - - //------------------------------------------------------------------ ::rtl::OUString ConvertLikeToken(const OSQLParseNode* pTokenNode, const OSQLParseNode* pEscapeNode, sal_Bool bInternational) { commit 1bc4a49d9ba99ff0531bafc2cf0183f726bfe14b Author: Lionel Elie Mamane <[email protected]> Date: Fri Apr 26 12:14:33 2013 +0200 QueryDesign: in criteria, remove column_ref when table *and* column name match As opposed to only the column name Change-Id: I261d13f23214f950daa55a5b63cd486e59a0e127 diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx index a7f8f04..bf8092f 100644 --- a/connectivity/source/commontools/predicateinput.cxx +++ b/connectivity/source/commontools/predicateinput.cxx @@ -268,7 +268,7 @@ namespace dbtools // translate it back into a string sTransformedText = OUString(); pParseNode->parseNodeToPredicateStr( - sTransformedText, m_xConnection, m_xFormatter, _rxField, + sTransformedText, m_xConnection, m_xFormatter, _rxField, OUString(), rParseContext.getPreferredLocale(), (sal_Char)nDecSeparator, &rParseContext ); _rPredicateValue = sTransformedText; diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 779283f..4c67ea3 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -140,6 +140,7 @@ namespace connectivity //----------------------------------------------------------------------------- SQLParseNodeParameter::SQLParseNodeParameter( const Reference< XConnection >& _rxConnection, const Reference< XNumberFormatter >& _xFormatter, const Reference< XPropertySet >& _xField, + const OUString &_sPredicateTableAlias, const Locale& _rLocale, const IParseContext* _pContext, bool _bIntl, bool _bQuote, sal_Char _cDecSep, bool _bPredicate, bool _bParseToSDBC ) :rLocale(_rLocale) @@ -148,6 +149,7 @@ SQLParseNodeParameter::SQLParseNodeParameter( const Reference< XConnection >& _r ,pSubQueryHistory( new QueryNameSet ) ,xFormatter(_xFormatter) ,xField(_xField) + ,sPredicateTableAlias(_sPredicateTableAlias) ,m_rContext( _pContext ? (const IParseContext&)(*_pContext) : (const IParseContext&)OSQLParser::s_aDefaultContext ) ,cDecSep(_cDecSep) ,bQuote(_bQuote) @@ -215,7 +217,7 @@ void OSQLParseNode::parseNodeToStr(OUString& rString, RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "[email protected]", "OSQLParseNode::parseNodeToStr" ); parseNodeToStr( - rString, _rxConnection, NULL, NULL, + rString, _rxConnection, NULL, NULL, OUString(), pContext ? pContext->getPreferredLocale() : OParseContext::getDefaultLocale(), pContext, _bIntl, _bQuote, '.', false, false ); } @@ -233,7 +235,7 @@ void OSQLParseNode::parseNodeToPredicateStr(OUString& rString, OSL_ENSURE(xFormatter.is(), "OSQLParseNode::parseNodeToPredicateStr:: no formatter!"); if (xFormatter.is()) - parseNodeToStr(rString, _rxConnection, xFormatter, NULL, rIntl, pContext, sal_True, sal_True, _cDec, true, false); + parseNodeToStr(rString, _rxConnection, xFormatter, NULL, OUString(), rIntl, pContext, sal_True, sal_True, _cDec, true, false); } //----------------------------------------------------------------------------- @@ -241,6 +243,7 @@ void OSQLParseNode::parseNodeToPredicateStr(OUString& rString, const Reference< XConnection > & _rxConnection, const Reference< XNumberFormatter > & xFormatter, const Reference< XPropertySet > & _xField, + const OUString &_sPredicateTableAlias, const ::com::sun::star::lang::Locale& rIntl, sal_Char _cDec, const IParseContext* pContext ) const @@ -250,7 +253,7 @@ void OSQLParseNode::parseNodeToPredicateStr(OUString& rString, OSL_ENSURE(xFormatter.is(), "OSQLParseNode::parseNodeToPredicateStr:: no formatter!"); if (xFormatter.is()) - parseNodeToStr( rString, _rxConnection, xFormatter, _xField, rIntl, pContext, true, true, _cDec, true, false ); + parseNodeToStr( rString, _rxConnection, xFormatter, _xField, _sPredicateTableAlias, rIntl, pContext, true, true, _cDec, true, false ); } //----------------------------------------------------------------------------- @@ -258,6 +261,7 @@ void OSQLParseNode::parseNodeToStr(OUString& rString, const Reference< XConnection > & _rxConnection, const Reference< XNumberFormatter > & xFormatter, const Reference< XPropertySet > & _xField, + const OUString &_sPredicateTableAlias, const ::com::sun::star::lang::Locale& rIntl, const IParseContext* pContext, bool _bIntl, @@ -277,7 +281,7 @@ void OSQLParseNode::parseNodeToStr(OUString& rString, { OSQLParseNode::impl_parseNodeToString_throw( sBuffer, SQLParseNodeParameter( - _rxConnection, xFormatter, _xField, rIntl, pContext, + _rxConnection, xFormatter, _xField, _sPredicateTableAlias, rIntl, pContext, _bIntl, _bQuote, _cDecSep, _bPredicate, _bSubstitute ) ); } @@ -299,7 +303,7 @@ bool OSQLParseNode::parseNodeToExecutableStatement( OUString& _out_rString, cons RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "[email protected]", "OSQLParseNode::parseNodeToExecutableStatement" ); OSL_PRECOND( _rxConnection.is(), "OSQLParseNode::parseNodeToExecutableStatement: invalid connection!" ); SQLParseNodeParameter aParseParam( _rxConnection, - NULL, NULL, OParseContext::getDefaultLocale(), NULL, false, true, '.', false, true ); + NULL, NULL, OUString(), OParseContext::getDefaultLocale(), NULL, false, true, '.', false, true ); if ( aParseParam.aMetaData.supportsSubqueriesInFrom() ) { @@ -340,7 +344,7 @@ namespace //----------------------------------------------------------------------------- void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "[email protected]", "OSQLParseNode::getTableRange" ); + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "[email protected]", "OSQLParseNode::impl_parseNodeToString_throw" ); if ( isToken() ) { parseLeaf(rString,rParam); @@ -477,10 +481,17 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const // "currentFieldName" = // but only at the very beginning of the criterion // (not embedded deep in the expression). - if (rString.isEmpty() && rParam.xField.is() && SQL_ISRULE(pSubTree,column_ref)) + // TODO: replace "beginning of criterion" by "in simple expression", + // that is anything made of: + // - parentheses + // - logical operators (and, or, not) + // - comparison operators (IS, =, >, <, BETWEEN, LIKE, ...) + // (see where the parser calls inPredicateCheck for a full list) + // but *not* e.g. in function arguments + if (rParam.bPredicate && rString.isEmpty() && rParam.xField.is() && SQL_ISRULE(pSubTree,column_ref)) { - sal_Bool bFilter = sal_False; - // retrieve the fields name + bool bFilter = false; + // retrieve the field's name & table range OUString aFieldName; try { @@ -496,21 +507,47 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const if(pSubTree->count()) { const OSQLParseNode* pCol = pSubTree->m_aChildren[pSubTree->count()-1]; - if ( ( SQL_ISRULE(pCol,column_val) - && pCol->getChild(0)->getTokenValue().equalsIgnoreAsciiCase(aFieldName) - ) - || pCol->getTokenValue().equalsIgnoreAsciiCase(aFieldName) + if (SQL_ISRULE(pCol,column_val)) + { + assert(pCol->count() == 1); + pCol = pCol->getChild(0); + } + const OSQLParseNode* pTable(NULL); + switch (pSubTree->count()) + { + case 1: + break; + case 3: + pTable = pSubTree->m_aChildren[0]; + break; + case 5: + case 7: + SAL_WARN("connectivity.parse", "SQL: catalog and/or schema in column_ref in predicate"); + break; + default: + SAL_WARN("connectivity.parse", "impl_parseNodeToString_throw: SQL grammar changed; column_ref has " << pSubTree->count() << " children"); + assert(false); + break; + } + // TODO: not all DBMS match column names case-insensitively... + // see XDatabaseMetaData::supportsMixedCaseIdentifiers() + // and XDatabaseMetaData::supportsMixedCaseQuotedIdentifiers() + if ( // table name matches (or no table name)? + ( !pTable || pTable->getTokenValue().equalsIgnoreAsciiCase(rParam.sPredicateTableAlias) ) + && // column name matches? + pCol->getTokenValue().equalsIgnoreAsciiCase(aFieldName) ) - bFilter = sal_True; + bFilter = true; } - // ok we found the field, if the following node is the - // comparision operator '=' we filter it as well if (bFilter) { + // skip field + ++i; + // if the following node is the comparision operator'=', + // we filter it as well if (SQL_ISRULE(this, comparison_predicate)) { - ++i; if(i != m_aChildren.end()) { pSubTree = *i; @@ -518,8 +555,6 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const ++i; } } - else - ++i; } else { diff --git a/connectivity/source/simpledbt/parsenode_s.cxx b/connectivity/source/simpledbt/parsenode_s.cxx index 6887cf3..92cd3a2 100644 --- a/connectivity/source/simpledbt/parsenode_s.cxx +++ b/connectivity/source/simpledbt/parsenode_s.cxx @@ -71,9 +71,11 @@ namespace connectivity //---------------------------------------------------------------- void OSimpleParseNode::parseNodeToPredicateStr(OUString& _rString, const Reference< XConnection >& _rxConnection, const Reference< XNumberFormatter >& _rxFormatter, const Reference< XPropertySet >& _rxField, + const OUString &_sPredicateTableAlias, const Locale& _rIntl, const sal_Char _cDecSeparator,const IParseContext* _pContext) const { - m_pFullNode->parseNodeToPredicateStr( _rString, _rxConnection, _rxFormatter, _rxField, _rIntl, _cDecSeparator, _pContext ); + m_pFullNode->parseNodeToPredicateStr( _rString, _rxConnection, _rxFormatter, _rxField, _sPredicateTableAlias, + _rIntl, _cDecSeparator, _pContext ); } //........................................................................ diff --git a/connectivity/source/simpledbt/parsenode_s.hxx b/connectivity/source/simpledbt/parsenode_s.hxx index d8bd6f9..0166933 100644 --- a/connectivity/source/simpledbt/parsenode_s.hxx +++ b/connectivity/source/simpledbt/parsenode_s.hxx @@ -54,6 +54,7 @@ namespace connectivity const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField, + const OUString &_sPredicateTableAlias, const ::com::sun::star::lang::Locale& _rIntl, const sal_Char _cDecSeparator, const IParseContext* _pContext diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index ad29c14..b54b381 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -1118,6 +1118,7 @@ sal_Bool OSelectionBrowseBox::SaveModified() xConnection, static_cast<OQueryController&>(getDesignView()->getController()).getNumberFormatter(), xColumn, + pEntry->GetAlias(), getDesignView()->getLocale(), static_cast<sal_Char>(getDesignView()->getDecimalSeparator().toChar()), &(static_cast<OQueryController&>(getDesignView()->getController()).getParser().getContext())); @@ -1157,6 +1158,7 @@ sal_Bool OSelectionBrowseBox::SaveModified() xConnection, static_cast<OQueryController&>(getDesignView()->getController()).getNumberFormatter(), xColumn, + pEntry->GetAlias(), getDesignView()->getLocale(), static_cast<sal_Char>(getDesignView()->getDecimalSeparator().toChar()), &(static_cast<OQueryController&>(getDesignView()->getController()).getParser().getContext())); diff --git a/include/connectivity/sqlnode.hxx b/include/connectivity/sqlnode.hxx index 940b27f..51a9ec2 100644 --- a/include/connectivity/sqlnode.hxx +++ b/include/connectivity/sqlnode.hxx @@ -82,6 +82,7 @@ namespace connectivity ::boost::shared_ptr< QueryNameSet > pSubQueryHistory; ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > xFormatter; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xField; + OUString sPredicateTableAlias; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > xQueries; // see bParseToSDBCLevel const IParseContext& m_rContext; sal_Char cDecSep; @@ -94,6 +95,7 @@ namespace connectivity const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, 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 OUString &_sPredicateTableAlias, const ::com::sun::star::lang::Locale& _rLocale, const IParseContext* _pContext, bool _bIntl, @@ -329,6 +331,7 @@ namespace connectivity const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, 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 OUString &_sTableAlias, const ::com::sun::star::lang::Locale& rIntl, sal_Char _cDec, const IParseContext* pContext = NULL ) const; @@ -410,6 +413,7 @@ namespace connectivity const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, 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 OUString &_sPredicateTableAlias, const ::com::sun::star::lang::Locale& rIntl, const IParseContext* pContext, bool _bIntl, diff --git a/include/connectivity/virtualdbtools.hxx b/include/connectivity/virtualdbtools.hxx index 352c98d..9083016 100644 --- a/include/connectivity/virtualdbtools.hxx +++ b/include/connectivity/virtualdbtools.hxx @@ -294,6 +294,7 @@ namespace connectivity const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField, + const OUString &_sPredicateTableAlias, const ::com::sun::star::lang::Locale& _rIntl, const sal_Char _cDecSeparator, const IParseContext* _pContext diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index f7dcf11..22b4716 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -2985,7 +2985,10 @@ sal_Bool DbFilterField::commitControl() xParseNode->parseNodeToPredicateStr(aPreparedText, xConnection, xNumberFormatter, - m_rColumn.GetField(),aAppLocale,'.', + m_rColumn.GetField(), + OUString(), + aAppLocale, + '.', getParseContext()); m_aText = aPreparedText; } diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index 9bd6570..8b665eb 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -903,7 +903,7 @@ sal_Bool FmFilterModel::ValidateText(FmFilterItem* pItem, OUString& rText, OUStr OUString aPreparedText; Locale aAppLocale = Application::GetSettings().GetUILanguageTag().getLocale(); xParseNode->parseNodeToPredicateStr( - aPreparedText, xConnection, xFormatter, xField, aAppLocale, '.', getParseContext() ); + aPreparedText, xConnection, xFormatter, xField, OUString(), aAppLocale, '.', getParseContext() ); rText = aPreparedText; return sal_True; } diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx index c9fab0b..313fcd8 100644 --- a/svx/source/form/formcontroller.cxx +++ b/svx/source/form/formcontroller.cxx @@ -3246,6 +3246,7 @@ void FormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos) ,xConnection ,xFormatter ,xField + ,OUString() ,aAppLocale ,cDecimalSeparator ,getParseContext()); commit fae7a3d060664e6540dbdfc3babd54ac9ccb45bf Author: Lionel Elie Mamane <[email protected]> Date: Fri Apr 26 02:59:26 2013 +0200 String -> OUString Change-Id: Ibf566a11a383b77a930d46967e496752c88b39e4 diff --git a/dbaccess/source/ui/inc/QueryDesignView.hxx b/dbaccess/source/ui/inc/QueryDesignView.hxx index 4b88212..f49614b 100644 --- a/dbaccess/source/ui/inc/QueryDesignView.hxx +++ b/dbaccess/source/ui/inc/QueryDesignView.hxx @@ -141,7 +141,7 @@ namespace dbaui ); ::connectivity::OSQLParseNode* getPredicateTreeFromEntry( OTableFieldDescRef pEntry, - const String& _sCriteria, + const OUString& _sCriteria, OUString& _rsErrorMessage, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn) const; diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 6f37036..fe27a41 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -3072,7 +3072,7 @@ void OQueryDesignView::SaveUIConfig() } // ----------------------------------------------------------------------------- OSQLParseNode* OQueryDesignView::getPredicateTreeFromEntry(OTableFieldDescRef pEntry, - const String& _sCriteria, + const OUString& _sCriteria, OUString& _rsErrorMessage, Reference<XPropertySet>& _rxColumn) const { @@ -3086,7 +3086,6 @@ OSQLParseNode* OQueryDesignView::getPredicateTreeFromEntry(OTableFieldDescRef pE ::connectivity::OSQLParser& rParser( static_cast<OQueryController&>(getController()).getParser() ); OQueryTableWindow* pWin = static_cast<OQueryTableWindow*>(pEntry->GetTabWindow()); - String sTest(_sCriteria); // special handling for functions if ( pEntry->GetFunctionType() & (FKT_OTHER | FKT_AGGREGATE | FKT_NUMERIC) ) { @@ -3157,6 +3156,7 @@ OSQLParseNode* OQueryDesignView::getPredicateTreeFromEntry(OTableFieldDescRef pE } } + OUString sTest(_sCriteria); OSQLParseNode* pParseNode = rParser.predicateTree( _rsErrorMessage, sTest, static_cast<OQueryController&>(getController()).getNumberFormatter(), commit e9ae448b1ed4424aadc183397d9f45b873ee3bc2 Author: Lionel Elie Mamane <[email protected]> Date: Fri Apr 26 02:52:36 2013 +0200 janitorial: indentation, spacing, ... Change-Id: Ie794e91783f8eaacf236070e7cdeb5b5f4361e9b diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 21275b4..779283f 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1232,8 +1232,8 @@ OSQLParseNode* OSQLParser::predicateTree(OUString& rErrorMessage, const OUString if (SQLyyparse() != 0) { m_sFieldName= OUString(); - m_xField.clear(); - m_xFormatter.clear(); + m_xField.clear(); + m_xFormatter.clear(); m_nFormatKey = 0; m_nDateFormatKey = 0; @@ -1253,8 +1253,8 @@ OSQLParseNode* OSQLParser::predicateTree(OUString& rErrorMessage, const OUString (*s_pGarbageCollector)->clear(); m_sFieldName= OUString(); - m_xField.clear(); - m_xFormatter.clear(); + m_xField.clear(); + m_xFormatter.clear(); m_nFormatKey = 0; m_nDateFormatKey = 0; @@ -1729,7 +1729,7 @@ sal_Bool OSQLParseNode::addDateValue(OUStringBuffer& rString, const SQLParseNode return sal_False; } // ----------------------------------------------------------------------------- -void OSQLParseNode::replaceNodeValue(const OUString& rTableAlias,const OUString& rColumnName) +void OSQLParseNode::replaceNodeValue(const OUString& rTableAlias, const OUString& rColumnName) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "[email protected]", "OSQLParseNode::replaceNodeValue" ); for (sal_uInt32 i=0;i<count();++i) @@ -1856,7 +1856,7 @@ void OSQLParseNode::disjunctiveNormalForm(OSQLParseNode*& pSearchCondition) } } //----------------------------------------------------------------------------- -void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition,sal_Bool bNegate) +void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition, sal_Bool bNegate) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "[email protected]", "OSQLParseNode::negateSearchCondition" ); if(!pSearchCondition) // no where condition at entry point commit e3d0f6ad119b8421a12d02c26d7410599ebb33e1 Author: Lionel Elie Mamane <[email protected]> Date: Fri Apr 26 02:51:37 2013 +0200 sal_Bool -> bool Change-Id: I157e0e84cbc9832dd863607b8f52359596b51c8c diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 391e6d6..21275b4 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -209,8 +209,8 @@ OUString OSQLParseNode::convertTimeString(const SQLParseNodeParameter& rParam, c void OSQLParseNode::parseNodeToStr(OUString& rString, const Reference< XConnection >& _rxConnection, const IParseContext* pContext, - sal_Bool _bIntl, - sal_Bool _bQuote) const + bool _bIntl, + bool _bQuote) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "[email protected]", "OSQLParseNode::parseNodeToStr" ); diff --git a/include/connectivity/sqlnode.hxx b/include/connectivity/sqlnode.hxx index f988f78..940b27f 100644 --- a/include/connectivity/sqlnode.hxx +++ b/include/connectivity/sqlnode.hxx @@ -314,8 +314,8 @@ namespace connectivity void parseNodeToStr(OUString& rString, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, const IParseContext* pContext = NULL, - sal_Bool _bIntl = sal_False, - sal_Bool _bQuote= sal_True) const; + bool _bIntl = sal_False, + bool _bQuote= sal_True) const; // quoted and internationalised void parseNodeToPredicateStr(OUString& rString, _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
