diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2013-07-11 16:53:23 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2013-07-11 17:53:30 +0200 |
commit | 40370f759c403c5f07fb4d77680bd8f954e55231 (patch) | |
tree | d720a2343ae95967dc19877423e7435b037f6b37 /connectivity | |
parent | ad1049716a6e62066a196c78b163c30af3a2d264 (diff) |
ORDER BY columns are prioritarily *SELECT* columns
as opposed to *table* columns,
and notwithstanding HSQLDB 1.8 (our embedded database) bugs.
Actually, supporting ORDER BY on non-select (but table) columns is OPTIONAL for DBMSs
(but quite common)
Change-Id: I6725dfda36b09429a78262bff6f3d3e3dd9032b6
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/parse/sqliterator.cxx | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 927dfa9c6b1f..af90f9919e5d 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -1868,7 +1868,9 @@ OUString OSQLParseTreeIterator::getUniqueColumnName(const OUString & rColumnName void OSQLParseTreeIterator::setOrderByColumnName(const OUString & rColumnName, OUString & rTableRange, sal_Bool bAscending) { SAL_INFO( "connectivity.parse", "parse Ocke.Janssen@sun.com OSQLParseTreeIterator::setOrderByColumnName" ); - Reference<XPropertySet> xColumn = findColumn( rColumnName, rTableRange, false ); + Reference<XPropertySet> xColumn = findSelectColumn( rColumnName ); + if ( !xColumn.is() ) + xColumn = findColumn ( rColumnName, rTableRange, false ); if ( xColumn.is() ) m_aOrderColumns->get().push_back(new OOrderColumn( xColumn, rTableRange, isCaseSensitive(), bAscending ) ); else @@ -2046,6 +2048,30 @@ const OSQLParseNode* OSQLParseTreeIterator::getSimpleHavingTree() const } // ----------------------------------------------------------------------------- +Reference< XPropertySet > OSQLParseTreeIterator::findSelectColumn( const OUString & rColumnName ) +{ + SAL_INFO( "connectivity.parse", "parse lionel@mamane.lu OSQLParseTreeIterator::findSelectColumn" ); + for ( OSQLColumns::Vector::const_iterator lookupColumn = m_aSelectColumns->get().begin(); + lookupColumn != m_aSelectColumns->get().end(); + ++lookupColumn ) + { + Reference< XPropertySet > xColumn( *lookupColumn ); + try + { + OUString sName, sTableName; + xColumn->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_NAME ) ) >>= sName; + if ( sName == rColumnName ) + return xColumn; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + return NULL; +} + +// ----------------------------------------------------------------------------- Reference< XPropertySet > OSQLParseTreeIterator::findColumn( const OUString & rColumnName, OUString & rTableRange, bool _bLookInSubTables ) { SAL_INFO( "connectivity.parse", "parse Ocke.Janssen@sun.com OSQLParseTreeIterator::findColumn" ); |