diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2023-05-24 22:15:26 +0200 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2023-05-25 08:28:25 +0200 |
commit | c557b30df03cb09ca7133d6921ece09a2a10eb3c (patch) | |
tree | c61300d4c0826cd31d5c2d7e725fc5bf708bd3cd /connectivity | |
parent | dc69e7c52f12f57197f26b56c968139186d4ed5b (diff) |
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 <serval2412@yahoo.fr>
Tested-by: Jenkins
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/mysqlc/mysqlc_table.cxx | 9 | ||||
-rw-r--r-- | connectivity/source/drivers/mysqlc/mysqlc_table.hxx | 4 |
2 files changed, 12 insertions, 1 deletions
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 |