diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2013-08-02 12:08:16 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-08-06 07:53:09 +0000 |
commit | df6c925fafabbc55693a945b47757bd799baac99 (patch) | |
tree | bfa9b0b0abdf9875ba2594e253071a409027af9d /dbaccess | |
parent | 5851030a8f97d5ea37464e4063e0b5d1c7cd7808 (diff) |
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@suse.cz>
Tested-by: Miklos Vajna <vmiklos@suse.cz>
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 32035e74e72b..22ae0e736c8e 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) |