added BATS, fix nil panic

This commit is contained in:
Andy Arthur
2022-10-21 16:12:27 -07:00
parent 6bfe87ad5f
commit b40cb00f00
2 changed files with 21 additions and 0 deletions

View File

@@ -977,6 +977,9 @@ func (root *RootValue) ValidateForeignKeysOnSchemas(ctx context.Context) (*RootV
func GetAllTagsForRoots(ctx context.Context, roots ...*RootValue) (tags schema.TagMapping, err error) {
tags = make(schema.TagMapping)
for _, root := range roots {
if root == nil {
continue
}
err = root.IterTables(ctx, func(tblName string, _ *Table, sch schema.Schema) (stop bool, err error) {
for _, t := range sch.GetAllCols().Tags {
tags.Add(t, tblName)

View File

@@ -412,3 +412,21 @@ SQL
[ $status -eq 0 ]
[[ $output =~ "clan_home_level | price_teleport | 0" ]] || false
}
@test "drop-create: ensure no tag collisions" {
dolt sql -q "CREATE TABLE my_table (pk int primary key)"
dolt commit -Am "added my_table"
run dolt schema tags
[ $status -eq 0 ]
[[ $output =~ "my_table | pk | 2803" ]] || false
dolt sql -q "DROP TABLE my_table"
dolt sql -q "CREATE TABLE mytable (pk int primary key)"
dolt sql -q "CREATE TABLE my_table (pk int primary key)"
run dolt schema tags
[ $status -eq 0 ]
[[ $output =~ "my_table | pk | 2803" ]] || false
[[ $output =~ "mytable | pk | 11671" ]] || false
}