diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2012-12-11 11:04:22 +0100 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2012-12-11 11:08:53 +0100 |
commit | c9a40d21fa4f657ae52d2765d284d12ccbe51c4f (patch) | |
tree | 1aa613c98c6ccb96ad30cd6af7a8c2919d382bae | |
parent | 22dadc5d1584fb7d161b4dabb9ff5152d5db5445 (diff) |
When parsing does not give a table name, take it from the column
Change-Id: Ie8a2c7e473d717cc22c51205dd8cdc59934de8b1
-rw-r--r-- | connectivity/inc/connectivity/sqliterator.hxx | 14 | ||||
-rw-r--r-- | connectivity/source/parse/sqliterator.cxx | 15 |
2 files changed, 16 insertions, 13 deletions
diff --git a/connectivity/inc/connectivity/sqliterator.hxx b/connectivity/inc/connectivity/sqliterator.hxx index 82f850501ca0..5da60c28c90a 100644 --- a/connectivity/inc/connectivity/sqliterator.hxx +++ b/connectivity/inc/connectivity/sqliterator.hxx @@ -69,7 +69,7 @@ namespace connectivity ::std::auto_ptr< OSQLParseTreeIteratorImpl > m_pImpl; - void traverseParameter(const OSQLParseNode* _pParseNode,const OSQLParseNode* _pColumnRef,const ::rtl::OUString& _aColumnName,const ::rtl::OUString& _aTableRange, const ::rtl::OUString& _rColumnAlias); + void traverseParameter(const OSQLParseNode* _pParseNode,const OSQLParseNode* _pColumnRef,const ::rtl::OUString& _aColumnName, ::rtl::OUString& _aTableRange, const ::rtl::OUString& _rColumnAlias); // inserts a table into the map void traverseOneTableName( OSQLTables& _rTables,const OSQLParseNode * pTableName, const ::rtl::OUString & rTableRange ); void traverseORCriteria(OSQLParseNode * pSearchCondition); @@ -92,25 +92,25 @@ namespace connectivity @param rColumnName the column name to look for @param rTableRange - the table alias name + the table alias name; if empty, look in all tables @return the desired column object, or <NULL/> if no such column could be found */ static ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > findColumn( - const OSQLTables& _rTables, const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange ); + const OSQLTables& _rTables, const ::rtl::OUString & rColumnName, ::rtl::OUString & rTableRange ); /** finds a column with a given name, belonging to a given table @param rColumnName the column name to look for @param rTableRange - the table alias name + the table alias name; if empty, look in all tables @param _bLookInSubTables <TRUE/> if and only if not only our direct tables, but also our sub tables (from sub selects) should be searched @return */ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > findColumn( - const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange, bool _bLookInSubTables ); + const ::rtl::OUString & rColumnName, ::rtl::OUString & rTableRange, bool _bLookInSubTables ); protected: void setSelectColumnName(::rtl::Reference<OSQLColumns>& _rColumns,const ::rtl::OUString & rColumnName,const ::rtl::OUString & rColumnAlias, const ::rtl::OUString & rTableRange,sal_Bool bFkt=sal_False,sal_Int32 _nType = com::sun::star::sdbc::DataType::VARCHAR,sal_Bool bAggFkt=sal_False); @@ -320,8 +320,8 @@ namespace connectivity */ void impl_getQueryParameterColumns( const OSQLTable& _rQuery ); - void setOrderByColumnName(const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange, sal_Bool bAscending); - void setGroupByColumnName(const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange); + void setOrderByColumnName(const ::rtl::OUString & rColumnName, ::rtl::OUString & rTableRange, sal_Bool bAscending); + void setGroupByColumnName(const ::rtl::OUString & rColumnName, ::rtl::OUString & rTableRange); private: /** appends an SQLException corresponding to the given error code to our error collection diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 7d91655b6394..d2a63e29251e 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -1441,7 +1441,7 @@ void OSQLParseTreeIterator::traverseANDCriteria(OSQLParseNode * pSearchCondition void OSQLParseTreeIterator::traverseParameter(const OSQLParseNode* _pParseNode ,const OSQLParseNode* _pParentNode ,const ::rtl::OUString& _aColumnName - ,const ::rtl::OUString& _aTableRange + ,::rtl::OUString& _aTableRange ,const ::rtl::OUString& _rColumnAlias) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseParameter" ); @@ -1908,7 +1908,7 @@ void OSQLParseTreeIterator::setSelectColumnName(::rtl::Reference<OSQLColumns>& _ return aAlias; } //----------------------------------------------------------------------------- -void OSQLParseTreeIterator::setOrderByColumnName(const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange,sal_Bool bAscending) +void OSQLParseTreeIterator::setOrderByColumnName(const ::rtl::OUString & rColumnName, ::rtl::OUString & rTableRange, sal_Bool bAscending) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::setOrderByColumnName" ); Reference<XPropertySet> xColumn = findColumn( rColumnName, rTableRange, false ); @@ -1930,7 +1930,7 @@ void OSQLParseTreeIterator::setOrderByColumnName(const ::rtl::OUString & rColumn #endif } //----------------------------------------------------------------------------- -void OSQLParseTreeIterator::setGroupByColumnName(const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange) +void OSQLParseTreeIterator::setGroupByColumnName(const ::rtl::OUString & rColumnName, ::rtl::OUString & rTableRange) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::setGroupByColumnName" ); Reference<XPropertySet> xColumn = findColumn( rColumnName, rTableRange, false ); @@ -2089,7 +2089,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getSimpleHavingTree() const } // ----------------------------------------------------------------------------- -Reference< XPropertySet > OSQLParseTreeIterator::findColumn( const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange, bool _bLookInSubTables ) +Reference< XPropertySet > OSQLParseTreeIterator::findColumn( const ::rtl::OUString & rColumnName, ::rtl::OUString & rTableRange, bool _bLookInSubTables ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::findColumn" ); Reference< XPropertySet > xColumn = findColumn( *m_pImpl->m_pTables, rColumnName, rTableRange ); @@ -2099,7 +2099,7 @@ Reference< XPropertySet > OSQLParseTreeIterator::findColumn( const ::rtl::OUStri } // ----------------------------------------------------------------------------- -Reference< XPropertySet > OSQLParseTreeIterator::findColumn(const OSQLTables& _rTables,const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange) +Reference< XPropertySet > OSQLParseTreeIterator::findColumn(const OSQLTables& _rTables, const ::rtl::OUString & rColumnName, ::rtl::OUString & rTableRange) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::findColumn" ); Reference< XPropertySet > xColumn; @@ -2115,7 +2115,7 @@ Reference< XPropertySet > OSQLParseTreeIterator::findColumn(const OSQLTables& _r } if ( !xColumn.is() ) { - OSQLTables::const_iterator aEnd = _rTables.end(); + const OSQLTables::const_iterator aEnd = _rTables.end(); for(OSQLTables::const_iterator aIter = _rTables.begin(); aIter != aEnd; ++aIter) { if ( aIter->second.is() ) @@ -2124,6 +2124,9 @@ Reference< XPropertySet > OSQLParseTreeIterator::findColumn(const OSQLTables& _r if( xColumns.is() && xColumns->hasByName(rColumnName) && (xColumns->getByName(rColumnName) >>= xColumn) ) { OSL_ENSURE(xColumn.is(),"Column isn't a propertyset!"); + // Cannot take "rTableRange = aIter->first" because that is the fully composed name + // that is, catalogName.schemaName.tableName + rTableRange = getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME))); break; // This column must only exits once } } |