Tag: cws_dev300_dba30c
User: oj      
Date: 2008-05-06 11:43:12+0000
Modified:
   dba/connectivity/inc/connectivity/dbtools.hxx
   dba/connectivity/source/commontools/dbtools2.cxx
   dba/connectivity/source/drivers/mysql/YTable.cxx
   dba/connectivity/source/drivers/mysql/YTables.cxx

Log:
 #i64472# change command can also change the name of a column

File Changes:

Directory: /dba/connectivity/inc/connectivity/
==============================================

File [changed]: dbtools.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/inc/connectivity/dbtools.hxx?r1=1.36&r2=1.36.10.1
Delta lines:  +14 -5
--------------------
--- dbtools.hxx 2008-04-10 07:36:41+0000        1.36
+++ dbtools.hxx 2008-05-06 11:43:09+0000        1.36.10.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dbtools.hxx,v $
- * $Revision: 1.36 $
+ * $Revision: 1.36.10.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -600,9 +600,12 @@
                        The descriptor of the new table.
                @param  _xConnection
                        The connection.
+        @param  _bAddScale
+            The scale will also be added when the value is 0.
        */
        ::rtl::OUString createStandardCreateStatement(  const 
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& 
descriptor,
-                                                                               
                        const ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XConnection>& _xConnection);
+                                                                               
                        const ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XConnection>& _xConnection,
+                                                    bool _bAddScale = false);
 
        /** creates the standard sql statement for the key part of a create 
table statement.
                @param  descriptor
@@ -618,20 +621,26 @@
                        The descriptor of the column.
                @param  _xConnection
                        The connection.
+        @param  _bAddScale
+            The scale will also be added when the value is 0.
        */
        ::rtl::OUString createStandardColumnPart(       const 
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& 
descriptor,
-                                                                               
                const ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XConnection>& _xConnection);
+                                                                               
                const ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XConnection>& _xConnection,
+                                                bool _bAddScale = false);
 
        /** creates a SQL CREATE TABLE statement
                @param  descriptor
                        The descriptor of the new table.
                @param  _xConnection
                        The connection.
+        @param  _bAddScale
+            The scale will also be added when the value is 0.
                @return
                        The CREATE TABLE statement.
        */
        ::rtl::OUString createSqlCreateTableStatement(  const 
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& 
descriptor,
-                                                                               
                        const ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XConnection>& _xConnection);
+                                                                               
                        const ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XConnection>& _xConnection,
+                                                    bool _bAddScale = false);
 
        /** creates a SDBC column with the help of getColumns.
                @param  _xTable

Directory: /dba/connectivity/source/commontools/
================================================

File [changed]: dbtools2.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/commontools/dbtools2.cxx?r1=1.27&r2=1.27.10.1
Delta lines:  +10 -9
--------------------
--- dbtools2.cxx        2008-04-10 08:01:30+0000        1.27
+++ dbtools2.cxx        2008-05-06 11:43:09+0000        1.27.10.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dbtools2.cxx,v $
- * $Revision: 1.27 $
+ * $Revision: 1.27.10.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -74,7 +74,7 @@
        using namespace connectivity;
        using namespace comphelper;
 
-::rtl::OUString createStandardColumnPart(const Reference< XPropertySet >& 
xColProp,const Reference< XConnection>& _xConnection)
+::rtl::OUString createStandardColumnPart(const Reference< XPropertySet >& 
xColProp,const Reference< XConnection>& _xConnection,bool _bAddScale)
 {
 
        Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
@@ -154,10 +154,10 @@
         if ( nPrecision > 0 && nDataType != DataType::TIMESTAMP )
         {
                    aSql += ::rtl::OUString::valueOf(nPrecision);
-            if ( nScale > 0 )
+            if ( (nScale > 0) || _bAddScale )
                 aSql += ::rtl::OUString::createFromAscii(",");
         }
-               if ( nScale > 0 || nDataType == DataType::TIMESTAMP )
+               if ( (nScale > 0) || _bAddScale || nDataType == 
DataType::TIMESTAMP )
                        aSql += ::rtl::OUString::valueOf(nScale);
 
         if ( nParenPos == -1 )
@@ -188,7 +188,7 @@
 }
 // 
-----------------------------------------------------------------------------
 
-::rtl::OUString createStandardCreateStatement(const Reference< XPropertySet >& 
descriptor,const Reference< XConnection>& _xConnection)
+::rtl::OUString createStandardCreateStatement(const Reference< XPropertySet >& 
descriptor,const Reference< XConnection>& _xConnection,bool _bAddScale)
 {
        ::rtl::OUString aSql    = ::rtl::OUString::createFromAscii("CREATE 
TABLE ");
        ::rtl::OUString sCatalog,sSchema,sTable,sComposedName;
@@ -220,7 +220,7 @@
        {
                if ( (xColumns->getByIndex(i) >>= xColProp) && xColProp.is() )
                {
-                       aSql += createStandardColumnPart(xColProp,_xConnection);
+                       aSql += 
createStandardColumnPart(xColProp,_xConnection,_bAddScale);
                        aSql += ::rtl::OUString::createFromAscii(",");
                }
        }
@@ -360,9 +360,10 @@
 }
 // 
-----------------------------------------------------------------------------
 ::rtl::OUString createSqlCreateTableStatement( const Reference< XPropertySet 
>& descriptor,
-                                                                               
                const Reference< XConnection>& _xConnection)
+                                                                               
                const Reference< XConnection>& _xConnection,
+                                                bool _bAddScale)
 {
-       ::rtl::OUString aSql = 
::dbtools::createStandardCreateStatement(descriptor,_xConnection);
+       ::rtl::OUString aSql = 
::dbtools::createStandardCreateStatement(descriptor,_xConnection,_bAddScale);
        ::rtl::OUString sKeyStmt = 
::dbtools::createStandardKeyStatement(descriptor,_xConnection);
        if ( sKeyStmt.getLength() )
                aSql += sKeyStmt;

Directory: /dba/connectivity/source/drivers/mysql/
==================================================

File [changed]: YTable.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/mysql/YTable.cxx?r1=1.12&r2=1.12.10.1
Delta lines:  +7 -5
-------------------
--- YTable.cxx  2008-04-10 10:23:29+0000        1.12
+++ YTable.cxx  2008-05-06 11:43:10+0000        1.12.10.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: YTable.cxx,v $
- * $Revision: 1.12 $
+ * $Revision: 1.12.10.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -222,6 +222,7 @@
                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 @@
                                }
                        }
                        alterColumnType(nNewType,colName,descriptor);
+            bColumnNameChanged = true;
                }
 
                // third: check the default values
@@ -275,14 +277,14 @@
                // 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(),true);
                        executeStatement(sSql);
                }
                m_pColumns->refresh();
@@ -311,7 +313,7 @@
        ::comphelper::copyProperties(_xDescriptor,xProp);
        
xProp->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),makeAny(nNewType));
 
-       sSql += ::dbtools::createStandardColumnPart(xProp,getConnection());
+       sSql += ::dbtools::createStandardColumnPart(xProp,getConnection(),true);
        executeStatement(sSql);
 }
 // 
-----------------------------------------------------------------------------

File [changed]: YTables.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/mysql/YTables.cxx?r1=1.12&r2=1.12.10.1
Delta lines:  +4 -4
-------------------
--- YTables.cxx 2008-04-10 10:23:47+0000        1.12
+++ YTables.cxx 2008-05-06 11:43:10+0000        1.12.10.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: YTables.cxx,v $
- * $Revision: 1.12 $
+ * $Revision: 1.12.10.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -189,8 +189,8 @@
 // -------------------------------------------------------------------------
 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();
+       const ::rtl::OUString aSql = 
::dbtools::createSqlCreateTableStatement(descriptor,xConnection,true);
 
     Reference< XStatement > xStmt = xConnection->createStatement(  );
        if ( xStmt.is() )




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to