Tag: cws_dev300_dba30c User: oj Date: 2008-05-08 07:15:30+0000 Modified: dba/connectivity/source/commontools/TKeys.cxx dba/connectivity/source/commontools/TTableHelper.cxx
Log: #i87131# collect keys only once, getKeys always refetch keys File Changes: Directory: /dba/connectivity/source/commontools/ ================================================ File [changed]: TKeys.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/commontools/TKeys.cxx?r1=1.12.10.1&r2=1.12.10.2 Delta lines: +14 -8 -------------------- --- TKeys.cxx 2008-05-05 10:57:50+0000 1.12.10.1 +++ TKeys.cxx 2008-05-08 07:15:27+0000 1.12.10.2 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: TKeys.cxx,v $ - * $Revision: 1.12.10.1 $ + * $Revision: 1.12.10.2 $ * * This file is part of OpenOffice.org. * @@ -182,26 +182,30 @@ } aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"))); + sal_Int32 nUpdateRule = 0, nDeleteRule = 0; + ::rtl::OUString sReferencedName; + if ( nKeyType == KeyType::FOREIGN ) { - ::rtl::OUString aRefTable; - - descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)) >>= aRefTable; + descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)) >>= sReferencedName; aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" REFERENCES ")) - + ::dbtools::quoteTableName(m_pTable->getConnection()->getMetaData(),aRefTable,::dbtools::eInTableDefinitions); + + ::dbtools::quoteTableName(m_pTable->getConnection()->getMetaData(),sReferencedName,::dbtools::eInTableDefinitions); aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" (")); for(sal_Int32 i=0;i<xColumns->getCount();++i) { - ::cppu::extractInterface(xColProp,xColumns->getByIndex(i)); + xColumns->getByIndex(i) >>= xColProp; aSql += ::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_RELATEDCOLUMN)))) + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(",")); } aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"))); - aSql += getKeyRuleString(sal_True ,getINT32(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_UPDATERULE)))); - aSql += getKeyRuleString(sal_False ,getINT32(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_DELETERULE)))); + descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_UPDATERULE)) >>= nUpdateRule; + descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_DELETERULE)) >>= nDeleteRule; + + aSql += getKeyRuleString(sal_True ,nUpdateRule); + aSql += getKeyRuleString(sal_False ,nDeleteRule); } Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); @@ -246,6 +250,8 @@ { } + m_pTable->addKey(sNewName,sdbcx::TKeyProperties(new sdbcx::KeyProperties(sReferencedName,nKeyType,nUpdateRule,nDeleteRule))); + return createObject( sNewName ); } // ----------------------------------------------------------------------------- File [changed]: TTableHelper.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/commontools/TTableHelper.cxx?r1=1.9.10.2&r2=1.9.10.3 Delta lines: +11 -1 -------------------- --- TTableHelper.cxx 2008-05-06 09:05:13+0000 1.9.10.2 +++ TTableHelper.cxx 2008-05-08 07:15:27+0000 1.9.10.3 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: TTableHelper.cxx,v $ - * $Revision: 1.9.10.2 $ + * $Revision: 1.9.10.3 $ * * This file is part of OpenOffice.org. * @@ -443,7 +443,17 @@ { pKeyProps = aFind->second; } + else // only a fall back + { + OSL_ENSURE(0,"No key with the given name found"); + pKeyProps.reset(new sdbcx::KeyProperties()); + } return pKeyProps; } // ----------------------------------------------------------------------------- +void OTableHelper::addKey(const ::rtl::OUString& _sName,const sdbcx::TKeyProperties& _aKeyProperties) +{ + m_aKeys.insert(TKeyMap::value_type(_sName,_aKeyProperties)); +} +// ----------------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
