summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2015-06-17 14:32:29 +0200
committerLionel Elie Mamane <lionel@mamane.lu>2015-06-17 14:33:23 +0200
commit09a490ddf516289b4ce2f70a19603b9590917632 (patch)
tree374fed750a6c1ede2b1e05b06ce920a94c139bd8 /connectivity
parent5652313e8a1aee00fd973cdcdd0d04071a8abd31 (diff)
parameter handling: fix confusion between column name and realname
Change-Id: I81fd45276183b911e4560ca785221894ea2ebc88
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/commontools/parameters.cxx34
1 files changed, 24 insertions, 10 deletions
diff --git a/connectivity/source/commontools/parameters.cxx b/connectivity/source/commontools/parameters.cxx
index 8459ae933c9a..1f94a59f1ede 100644
--- a/connectivity/source/commontools/parameters.cxx
+++ b/connectivity/source/commontools/parameters.cxx
@@ -105,6 +105,8 @@ namespace dbtools
m_aMasterFields.realloc( 0 );
m_aDetailFields.realloc( 0 );
m_sIdentifierQuoteString.clear();
+ m_sSpecialCharacters.clear();
+ m_xConnectionMetadata.clear();
::std::vector< bool > aEmptyArray;
m_aParametersVisited.swap( aEmptyArray );
m_bUpToDate = false;
@@ -208,24 +210,32 @@ namespace dbtools
OUString ParameterManager::createFilterConditionFromColumnLink(
- const OUString& _rMasterColumn, const OUString& _rDetailLink, OUString& _rNewParamName )
+ const OUString &_rMasterColumn, const Reference < XPropertySet > &xDetailField, OUString &o_rNewParamName )
{
OUString sFilter;
-
// format is:
// <detail_column> = :<new_param_name>
- sFilter = quoteName( m_sIdentifierQuoteString, _rDetailLink );
- sFilter += " = :";
+ {
+ OUString tblName;
+ xDetailField->getPropertyValue("TableName") >>= tblName;
+ if (!tblName.isEmpty())
+ sFilter = ::dbtools::quoteTableName( m_xConnectionMetadata, tblName, ::dbtools::eInDataManipulation ) + ".";
+ }
+ {
+ OUString colName;
+ xDetailField->getPropertyValue("RealName") >>= colName;
+ sFilter += quoteName( m_sIdentifierQuoteString, colName ) + " = :";
+ }
// generate a parameter name which is not already used
- _rNewParamName = "link_from_";
- _rNewParamName += convertName2SQLName( _rMasterColumn, m_sSpecialCharacters );
- while ( m_aParameterInformation.find( _rNewParamName ) != m_aParameterInformation.end() )
+ o_rNewParamName = "link_from_";
+ o_rNewParamName += convertName2SQLName( _rMasterColumn, m_sSpecialCharacters );
+ while ( m_aParameterInformation.find( o_rNewParamName ) != m_aParameterInformation.end() )
{
- _rNewParamName += "_";
+ o_rNewParamName += "_";
}
- return sFilter += _rNewParamName;
+ return sFilter += o_rNewParamName;
}
@@ -279,8 +289,11 @@ namespace dbtools
// does the detail name denote a column?
if ( _rxColumns->hasByName( *pDetailFields ) )
{
+ Reference< XPropertySet > xDetailField(_rxColumns->getByName( *pDetailFields ), UNO_QUERY);
+ assert(xDetailField.is());
+
OUString sNewParamName;
- const OUString sFilterCondition = createFilterConditionFromColumnLink( *pMasterFields, *pDetailFields, sNewParamName );
+ const OUString sFilterCondition = createFilterConditionFromColumnLink( *pMasterFields, xDetailField, sNewParamName );
OSL_PRECOND( !sNewParamName.isEmpty(), "ParameterManager::classifyLinks: createFilterConditionFromColumnLink returned nonsense!" );
// remember meta information about this new parameter
@@ -754,6 +767,7 @@ namespace dbtools
xMeta = xConnection->getMetaData();
if ( xMeta.is() )
{
+ m_xConnectionMetadata = xMeta;
m_sIdentifierQuoteString = xMeta->getIdentifierQuoteString();
m_sSpecialCharacters = xMeta->getExtraNameCharacters();
}