From c557b30df03cb09ca7133d6921ece09a2a10eb3c Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Wed, 24 May 2023 22:15:26 +0200 Subject: [PATCH] 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 Tested-by: Jenkins --- connectivity/source/drivers/mysqlc/mysqlc_table.cxx | 9 ++++++++- connectivity/source/drivers/mysqlc/mysqlc_table.hxx | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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& descriptor) override; + + /** returns the ALTER TABLE XXX statement + */ + OUString getAlterTableColumnPart() const; }; } // namespace connectivity::mysqlc