[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - dbaccess/source

Lionel Elie Mamane lionel at mamane.lu
Tue Aug 6 00:53:30 PDT 2013


 dbaccess/source/core/api/SingleSelectQueryComposer.cxx |   22 +++++++++++------
 1 file changed, 15 insertions(+), 7 deletions(-)

New commits:
commit df6c925fafabbc55693a945b47757bd799baac99
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Fri Aug 2 12:08:16 2013 +0200

    SingleSelectQueryComposer: the name of a non-SELECT column is its "real" name
    
    That is, the name in the table.
    
    Change-Id: I95326915f381ec0cf72c66f13352ce76d82e9517
    Reviewed-on: https://gerrit.libreoffice.org/5247
    Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
    Tested-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index 32035e7..22ae0e7 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -542,21 +542,29 @@ OUString OSingleSelectQueryComposer::impl_getColumnName_throw(const Reference< X
             throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,makeAny(aErr) );
         }
 
-    OUString aName, aNewName;
+    OUString aName;
     column->getPropertyValue(PROPERTY_NAME)         >>= aName;
 
+    const OUString aQuote  = m_xMetaData->getIdentifierQuoteString();
+
+    if ( m_aCurrentColumns[SelectColumns] &&
+         m_aCurrentColumns[SelectColumns]->hasByName(aName) )
+    {
+        // It is a column from the SELECT list, use it as such.
+        return ::dbtools::quoteName(aQuote,aName);
+    }
+
+    // Nope, it is an unrelated column.
+    // Is that supported?
     if ( bOrderBy &&
-         !m_xMetaData->supportsOrderByUnrelated() &&
-         m_aCurrentColumns[SelectColumns] &&
-         !m_aCurrentColumns[SelectColumns]->hasByName(aName) )
+         !m_xMetaData->supportsOrderByUnrelated() )
     {
         OUString sError(DBACORE_RESSTRING(RID_STR_COLUMN_MUST_VISIBLE));
         throw SQLException(sError.replaceAll("%name", aName),*this,SQLSTATE_GENERAL,1000,Any() );
     }
 
-    const OUString aQuote  = m_xMetaData->getIdentifierQuoteString();
-    aNewName = ::dbtools::quoteName(aQuote,aName);
-    return aNewName;
+    // We need to refer to it by its "real" name, that is by schemaName.tableName.columnNameInTable
+    return impl_getColumnRealName_throw(column, false);
 }
 
 void SAL_CALL OSingleSelectQueryComposer::appendOrderByColumn( const Reference< XPropertySet >& column, sal_Bool ascending ) throw(SQLException, RuntimeException)


More information about the Libreoffice-commits mailing list