From 1ae1fe1d6ca4cb1658234ec5c196f41e43525e13 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 31 Oct 2022 12:08:50 +0200 Subject: 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 (cherry picked from commit 85a5233275ab83fe0d6b943b298695387d97accd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141931 Tested-by: Noel Grandin --- dbaccess/source/ui/uno/copytablewizard.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index dfc179ff367c..4404c9595c1d 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -1380,7 +1380,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; -- cgit