dbaccess/source/ui/uno/copytablewizard.cxx |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit d1d6815ad04fb5ae80899fd41a94fcf36a479fe1
Author:     Noel Grandin <[email protected]>
AuthorDate: Mon Oct 31 12:08:50 2022 +0200
Commit:     Xisco Fauli <[email protected]>
CommitDate: Tue Nov 1 14:00:23 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 <[email protected]>
    (cherry picked from commit 85a5233275ab83fe0d6b943b298695387d97accd)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141932
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx 
b/dbaccess/source/ui/uno/copytablewizard.cxx
index 127085602482..583811eef79b 100644
--- a/dbaccess/source/ui/uno/copytablewizard.cxx
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -1361,7 +1361,9 @@ void CopyTableWizard::impl_doCopy_nothrow()
                 // tdf#119962
                 const Reference< XDatabaseMetaData > xDestMetaData( 
m_xDestConnection->getMetaData(), UNO_SET_THROW );
                 OUString sDatabaseDest = 
xDestMetaData->getDatabaseProductName().toAsciiLowerCase();
-                if ( (sDatabaseDest.indexOf("hsql") != -1) || 
(sDatabaseDest.indexOf("firebird") != -1) )
+                // If we created a new primary key, then it won't necessarily 
be an IDENTITY column
+                const bool bShouldCreatePrimaryKey = 
rWizard.shouldCreatePrimaryKey();
+                if ( !bShouldCreatePrimaryKey && 
((sDatabaseDest.indexOf("hsql") != -1) || (sDatabaseDest.indexOf("firebird") != 
-1)) )
                 {
                     const OUString sComposedTableName = 
::dbtools::composeTableName( xDestMetaData, xTable, 
::dbtools::EComposeRule::InDataManipulation, true );
 

Reply via email to