diff options
author | Oliver Bolte <obo@openoffice.org> | 2009-02-18 07:15:37 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2009-02-18 07:15:37 +0000 |
commit | a8c88dd0b80ea3f4411d3a98c818ec4bd0b011aa (patch) | |
tree | 63d8eff33ec30e22c1cd41c84b951946db685fd3 /connectivity/source/parse/sqliterator.cxx | |
parent | 2ae3df202e5864bb9beb2e01a88be554b9c897f5 (diff) |
CWS-TOOLING: integrate CWS dba31i
2009-02-12 09:37:16 +0100 fs r267635 : merging the fix for #i98549# from CWS rptfix04 to CWS dba31i
2009-02-09 10:09:03 +0100 fs r267502 : #i98467#
2009-02-03 14:40:59 +0100 fs r267328 : #i97159# +checkParameterTypes
2009-02-03 14:40:32 +0100 fs r267327 : some more data / correct query 'all orders'
2009-02-03 14:16:56 +0100 fs r267321 : #i97159# properly determine column alias / table range for parameters in BETWEEN clauses
2009-02-03 12:39:40 +0100 oj r267313 : #i97159# check for column range in parameter
2009-02-03 10:17:29 +0100 fs r267300 : #i98247#
2009-02-02 12:21:18 +0100 oj r267258 : #i98724# subst corrected
Diffstat (limited to 'connectivity/source/parse/sqliterator.cxx')
-rw-r--r-- | connectivity/source/parse/sqliterator.cxx | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index c1432d90c3f8..891fd41dae3f 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -1066,6 +1066,26 @@ bool OSQLParseTreeIterator::traverseGroupByColumnNames(const OSQLParseNode* pSel traverseByColumnNames( pSelectNode, sal_False ); return !hasErrors(); } + +// ----------------------------------------------------------------------------- +namespace +{ + ::rtl::OUString lcl_generateParameterName( const OSQLParseNode& _rParentNode, const OSQLParseNode& _rParamNode ) + { + ::rtl::OUString sColumnName( RTL_CONSTASCII_USTRINGPARAM( "param" ) ); + const sal_Int32 nCount = (sal_Int32)_rParentNode.count(); + for ( sal_Int32 i = 0; i < nCount; ++i ) + { + if ( _rParentNode.getChild(i) == &_rParamNode ) + { + sColumnName += ::rtl::OUString::valueOf( i+1 ); + break; + } + } + return sColumnName; + } +} + // ----------------------------------------------------------------------------- void OSQLParseTreeIterator::traverseParameters(const OSQLParseNode* _pNode) { @@ -1081,33 +1101,34 @@ void OSQLParseTreeIterator::traverseParameters(const OSQLParseNode* _pNode) sal_uInt32 nPos = 0; if ( pParent->getChild(nPos) == _pNode ) nPos = 2; - pParent->getChild(nPos)->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + const OSQLParseNode* pOther = pParent->getChild(nPos); + if ( SQL_ISRULE( pOther, column_ref ) ) + getColumnRange( pOther, sColumnName, sTableRange, aColumnAlias); + else + pOther->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); } // if ( SQL_ISRULE(pParent,comparison_predicate) ) // x = X else if ( SQL_ISRULE(pParent,like_predicate) ) { - pParent->getChild(0)->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + const OSQLParseNode* pOther = pParent->getChild(0); + if ( SQL_ISRULE( pOther, column_ref ) ) + getColumnRange( pOther, sColumnName, sTableRange, aColumnAlias); + else + pOther->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); } else if ( SQL_ISRULE(pParent,between_predicate) ) { - sal_Int32 nPos = 2; - if ( pParent->getChild(3) == _pNode ) - nPos = 1; - pParent->getChild(0)->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); - sColumnName += ::rtl::OUString::valueOf(nPos); + const OSQLParseNode* pOther = pParent->getChild(0); + if ( SQL_ISRULE( pOther, column_ref ) ) + getColumnRange( pOther, sColumnName, sTableRange, aColumnAlias); + else + { + pOther->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + lcl_generateParameterName( *pParent, *_pNode ); + } } else if ( pParent->getNodeType() == SQL_NODE_COMMALISTRULE ) { - const sal_Int32 nParamCount = (sal_Int32)pParent->count(); - for (sal_Int32 i = 0; i < nParamCount; ++i) - { - if ( pParent->getChild(i) == _pNode ) - { - static const ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM("param")); - sColumnName = s_sParam; - sColumnName += ::rtl::OUString::valueOf(i+1); - break; - } - } + lcl_generateParameterName( *pParent, *_pNode ); } } traverseParameter( _pNode, pParent, sColumnName, sTableRange, aColumnAlias ); |