connectivity/source/drivers/mysqlc/mysqlc_table.cxx |    9 ++++++++-
 connectivity/source/drivers/mysqlc/mysqlc_table.hxx |    4 ++++
 2 files changed, 12 insertions(+), 1 deletion(-)

New commits:
commit c557b30df03cb09ca7133d6921ece09a2a10eb3c
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Wed May 24 22:15:26 2023 +0200
Commit:     Julien Nabet <serval2...@yahoo.fr>
CommitDate: Thu May 25 08:28:25 2023 +0200

    tdf#155443: MySQL/MariaDB direct connect: pb to change fieldname in table
    
    Copy and simplify "getAlterTableColumnPart" from Mysql JDBC part which seems
    to do the right job with table name.
    
    Change-Id: I94d20b002a60f2ce1ea4d7e4de8040a9cbf04994
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152247
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>
    Tested-by: Jenkins

diff --git a/connectivity/source/drivers/mysqlc/mysqlc_table.cxx 
b/connectivity/source/drivers/mysqlc/mysqlc_table.cxx
index 13d7480998c3..aa2bd528e93e 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_table.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_table.cxx
@@ -135,7 +135,7 @@ void SAL_CALL 
connectivity::mysqlc::Table::alterColumnByName(
     {
         OUString sNewColName;
         rDescriptor->getPropertyValue("Name") >>= sNewColName;
-        OUString sSql("ALTER TABLE `" + getName() + "` RENAME COLUMN `" + 
rColName + "` TO `"
+        OUString sSql(getAlterTableColumnPart() + " RENAME COLUMN `" + 
rColName + "` TO `"
                       + sNewColName + "`");
 
         getConnection()->createStatement()->execute(sSql);
@@ -155,6 +155,13 @@ void SAL_CALL 
connectivity::mysqlc::Table::alterColumnByIndex(
                       descriptor);
 }
 
+OUString connectivity::mysqlc::Table::getAlterTableColumnPart() const
+{
+    return "ALTER TABLE "
+           + ::dbtools::composeTableName(getMetaData(), m_CatalogName, 
m_SchemaName, m_Name, true,
+                                         
::dbtools::EComposeRule::InTableDefinitions);
+}
+
 OUString connectivity::mysqlc::Table::getRenameStart() const { return "RENAME 
TABLE "; }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_table.hxx 
b/connectivity/source/drivers/mysqlc/mysqlc_table.hxx
index f17a326878f9..7487f1bc7b34 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_table.hxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_table.hxx
@@ -58,6 +58,10 @@ public:
 
     virtual void SAL_CALL alterColumnByIndex(
         sal_Int32 index, const css::uno::Reference<css::beans::XPropertySet>& 
descriptor) override;
+
+    /** returns the ALTER TABLE XXX statement
+    */
+    OUString getAlterTableColumnPart() const;
 };
 
 } // namespace connectivity::mysqlc

Reply via email to