dbaccess/source/ui/uno/copytablewizard.cxx | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
New commits: commit c87315bd90cad77b20cf4980e83c636082acf11e Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Oct 31 12:08:50 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Nov 2 06:58:09 2022 +0100 error when copying table and the copy table wizard creates the primary key then the primary key will not be IDENTITY column, and the ALTER TABLE...RESTART WITH will product an error Change-Id: If17bd0cbfe3519f9074aebb819b7d85ccea63e1a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141970 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit 85a5233275ab83fe0d6b943b298695387d97accd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142141 Tested-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index b4b6873c874e..777ba0288c01 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -1368,17 +1368,6 @@ void CopyTableWizard::impl_doCopy_nothrow() // tdf#119962 const Reference< XDatabaseMetaData > xDestMetaData( m_xDestConnection->getMetaData(), UNO_SET_THROW ); - const OUString sComposedTableName = ::dbtools::composeTableName( xDestMetaData, xTable, ::dbtools::EComposeRule::InDataManipulation, true ); - - OUString aSchema,aTable; - xTable->getPropertyValue("SchemaName") >>= aSchema; - xTable->getPropertyValue("Name") >>= aTable; - Any aCatalog = xTable->getPropertyValue("CatalogName"); - - const Reference< XResultSet > xResultPKCL(xDestMetaData->getPrimaryKeys(aCatalog,aSchema,aTable)); - Reference< XRow > xRowPKCL(xResultPKCL, UNO_QUERY_THROW); - OUString sPKCL; - if ( xRowPKCL.is() ) { if (xResultPKCL->next()) { @@ -1386,7 +1375,9 @@ void CopyTableWizard::impl_doCopy_nothrow() } } - if (!sPKCL.isEmpty()) + // If we created a new primary key, then it won't necessarily be an IDENTITY column + const bool bShouldCreatePrimaryKey = rWizard.shouldCreatePrimaryKey(); + if (!bShouldCreatePrimaryKey && !sPKCL.isEmpty()) { OUString strSql = "SELECT MAX(\"" + sPKCL + "\") FROM " + sComposedTableName;