From d0491f57371e72bd44415cd81197dfcf54af138f Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 25 Jun 2013 04:17:51 +0000 Subject: [PATCH] Support auto_increment flag on unique key columns, in copy table dialog. Fixes issue #3250. --- source/copytable.pas | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/copytable.pas b/source/copytable.pas index 6860ae68..eb0e5b8c 100644 --- a/source/copytable.pas +++ b/source/copytable.pas @@ -362,7 +362,7 @@ var CreateCode, InsertCode, TargetTable, DataCols: String; TableExistence: String; ParentNode, Node: PVirtualNode; - DoData, AutoIncGetsPrimaryKey, AutoIncRemoved, TableHasAutoInc: Boolean; + DoData, AutoIncGetsKey, AutoIncRemoved, TableHasAutoInc: Boolean; SelectedColumns: TTableColumnList; SelectedKeys: TTableKeyList; SelectedForeignKeys: TForeignKeyList; @@ -422,16 +422,16 @@ begin // Columns code. Remove auto_increment attribute if pkey was unchecked, to overcome // "there can be only one auto column and it must be defined as a key" for Column in SelectedColumns do begin - AutoIncGetsPrimaryKey := False; + AutoIncGetsKey := False; AutoIncRemoved := False; if Column.DefaultType = cdtAutoInc then begin for Key in SelectedKeys do begin - if (Key.IndexType = PKEY) and (Key.Columns.IndexOf(Column.Name) > -1) then begin - AutoIncGetsPrimaryKey := True; + if ((Key.IndexType = PKEY) or (Key.IndexType = UKEY)) and (Key.Columns.IndexOf(Column.Name) > -1) then begin + AutoIncGetsKey := True; Break; end; end; - if not AutoIncGetsPrimaryKey then begin + if not AutoIncGetsKey then begin Column.DefaultType := cdtNothing; AutoIncRemoved := True; end;