diff options
author | Rüdiger Timm <rt@openoffice.org> | 2008-06-06 12:23:34 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2008-06-06 12:23:34 +0000 |
commit | adaf80a7410ee81d734f5389fdc855dff897819b (patch) | |
tree | dd607e10e4ce33f725bc176513b76f048dbfd699 | |
parent | 593cdcf7a001948bbbc1ae78c178f302a105773b (diff) |
INTEGRATION: CWS dba30c (1.12.10); FILE MERGED
2008/05/08 12:55:51 oj 1.12.10.2: #i64472# use of create pattern
2008/05/06 11:43:10 oj 1.12.10.1: #i64472# change command can also change the name of a column
-rw-r--r-- | connectivity/source/drivers/mysql/YTable.cxx | 16 | ||||
-rw-r--r-- | connectivity/source/drivers/mysql/YTables.cxx | 7 |
2 files changed, 16 insertions, 7 deletions
diff --git a/connectivity/source/drivers/mysql/YTable.cxx b/connectivity/source/drivers/mysql/YTable.cxx index fbfe52b7fd08..8a951936c23c 100644 --- a/connectivity/source/drivers/mysql/YTable.cxx +++ b/connectivity/source/drivers/mysql/YTable.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: YTable.cxx,v $ - * $Revision: 1.12 $ + * $Revision: 1.13 $ * * This file is part of OpenOffice.org. * @@ -222,6 +222,7 @@ void SAL_CALL OMySQLTable::alterColumnByName( const ::rtl::OUString& colName, co sal_Bool bOldAutoIncrement = sal_False,bAutoIncrement = sal_False; xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bOldAutoIncrement; descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bAutoIncrement; + bool bColumnNameChanged = false; if ( nOldType != nNewType || nOldPrec != nNewPrec @@ -256,6 +257,7 @@ void SAL_CALL OMySQLTable::alterColumnByName( const ::rtl::OUString& colName, co } } alterColumnType(nNewType,colName,descriptor); + bColumnNameChanged = true; } // third: check the default values @@ -275,14 +277,14 @@ void SAL_CALL OMySQLTable::alterColumnByName( const ::rtl::OUString& colName, co // now we should look if the name of the column changed ::rtl::OUString sNewColumnName; descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_NAME)) >>= sNewColumnName; - if ( !sNewColumnName.equalsIgnoreAsciiCase(colName) ) + if ( !sNewColumnName.equalsIgnoreAsciiCase(colName) && !bColumnNameChanged ) { ::rtl::OUString sSql = getAlterTableColumnPart(); sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" CHANGE ")); const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( ); sSql += ::dbtools::quoteName(sQuote,colName); sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ")); - sSql += ::dbtools::createStandardColumnPart(descriptor,getConnection()); + sSql += ::dbtools::createStandardColumnPart(descriptor,getConnection(),getTypeCreatePattern()); executeStatement(sSql); } m_pColumns->refresh(); @@ -311,10 +313,16 @@ void OMySQLTable::alterColumnType(sal_Int32 nNewType,const ::rtl::OUString& _rCo ::comphelper::copyProperties(_xDescriptor,xProp); xProp->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),makeAny(nNewType)); - sSql += ::dbtools::createStandardColumnPart(xProp,getConnection()); + sSql += ::dbtools::createStandardColumnPart(xProp,getConnection(),getTypeCreatePattern()); executeStatement(sSql); } // ----------------------------------------------------------------------------- +::rtl::OUString OMySQLTable::getTypeCreatePattern() const +{ + static const ::rtl::OUString s_sCreatePattern(RTL_CONSTASCII_USTRINGPARAM("(M,D)")); + return s_sCreatePattern; +} +// ----------------------------------------------------------------------------- void OMySQLTable::alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName) { ::rtl::OUString sSql = getAlterTableColumnPart(); diff --git a/connectivity/source/drivers/mysql/YTables.cxx b/connectivity/source/drivers/mysql/YTables.cxx index 692bf2fc7290..b835909d2c63 100644 --- a/connectivity/source/drivers/mysql/YTables.cxx +++ b/connectivity/source/drivers/mysql/YTables.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: YTables.cxx,v $ - * $Revision: 1.12 $ + * $Revision: 1.13 $ * * This file is part of OpenOffice.org. * @@ -189,8 +189,9 @@ void OTables::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName) // ------------------------------------------------------------------------- void OTables::createTable( const Reference< XPropertySet >& descriptor ) { - Reference< XConnection > xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection(); - ::rtl::OUString aSql = ::dbtools::createSqlCreateTableStatement(descriptor,xConnection); + const Reference< XConnection > xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection(); + static const ::rtl::OUString s_sCreatePattern(RTL_CONSTASCII_USTRINGPARAM("(M,D)")); + const ::rtl::OUString aSql = ::dbtools::createSqlCreateTableStatement(descriptor,xConnection,s_sCreatePattern); Reference< XStatement > xStmt = xConnection->createStatement( ); if ( xStmt.is() ) |