constraint equal reverted

This commit is contained in:
James Cor
2022-03-07 13:32:36 -08:00
parent 60201b2485
commit b16a08a4c3
3 changed files with 10 additions and 4 deletions

View File

@@ -40,9 +40,9 @@ func DropPrimaryKeyFromTable(ctx context.Context, table *doltdb.Table, nbf *type
newCollection := schema.MapColCollection(sch.GetAllCols(), func(col schema.Column) schema.Column {
col.IsPartOfPK = false
// Removing PK does not remove NOT NULL constraint, so add it back if it's somehow gone
if col.IsNullable() {
col.Constraints = append(col.Constraints, schema.NotNullConstraint{})
}
//if col.IsNullable() {
// col.Constraints = append(col.Constraints, schema.NotNullConstraint{})
//}
return col
})

View File

@@ -93,6 +93,12 @@ func IndexOfConstraint(constraints []ColConstraint, constraintType string) int {
// ColConstraintsAreEqual validates two ColConstraint slices are identical.
func ColConstraintsAreEqual(a, b []ColConstraint) bool {
// kinda shitty. Probably shouldn't require order to be identical
if len(a) != len(b) {
return false
} else if len(a) == 0 {
return true
}
for i := 0; i < len(a); i++ {
ca, cb := a[i], b[i]

View File

@@ -63,7 +63,7 @@ func encodeAllColConstraints(constraints []schema.ColConstraint) []encodedConstr
for _, c := range constraints {
if c.GetConstraintType() == schema.NotNullConstraintType {
if seenNotNull {
continue
//continue
}
seenNotNull = true
}