diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2013-08-02 12:08:16 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2013-08-02 13:57:47 +0200 |
commit | 6fc71eea1d11d0d373ad32052d25f65e800509e7 (patch) | |
tree | 6409d0fade6419e897dedf367070652fa90fe0ff /dbaccess | |
parent | 69a061509b728055c0f30f36427e2efa63424cbd (diff) |
SingleSelectQueryComposer: the name of a non-SELECT column is its "real" name
That is, the name in the table.
Change-Id: I95326915f381ec0cf72c66f13352ce76d82e9517
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 58a5564f88e3..cb65b4bacb7c 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -541,21 +541,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) |