Skip to content

Commit 14a7c3c

Browse files
author
James Cor
committed
catch duplicates
1 parent b2de759 commit 14a7c3c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sql/planbuilder/ddl.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,20 @@ func (b *Builder) buildCreateTableLike(inScope *scope, ct *ast.DDL) *scope {
452452
}
453453
}
454454

455+
var hasSkippedCols bool
455456
for _, col := range pkSch.Schema {
457+
name := strings.ToLower(col.Name)
458+
if _, ok := newSchMap[name]; ok {
459+
// TODO: throw warning
460+
hasSkippedCols = true
461+
continue
462+
}
456463
newSch = append(newSch, col)
457464
}
458-
for _, pkOrd := range pkSch.PkOrdinals {
459-
pkOrdinals = append(pkOrdinals, len(newSch)+pkOrd)
465+
if !hasSkippedCols {
466+
for _, pkOrd := range pkSch.PkOrdinals {
467+
pkOrdinals = append(pkOrdinals, len(newSch)+pkOrd)
468+
}
460469
}
461470

462471
pkSchema := sql.NewPrimaryKeySchema(newSch, pkOrdinals...)

0 commit comments

Comments
 (0)