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
This commit is contained in:
Julien Nabet 2023-05-24 22:15:26 +02:00
parent dc69e7c52f
commit c557b30df0
2 changed files with 12 additions and 1 deletions

View File

@ -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: */

View File

@ -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