MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestPartitionTable_CreateIndex

Function TestPartitionTable_CreateIndex

backend/store/model/database_test.go:98–129  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestPartitionTable_CreateIndex(t *testing.T) {
99 a := require.New(t)
100
101 // Create a table with partitions
102 tableProto := &storepb.TableMetadata{
103 Name: "orders",
104 Columns: []*storepb.ColumnMetadata{
105 {Name: "id"},
106 {Name: "created_at"},
107 },
108 Partitions: []*storepb.TablePartitionMetadata{
109 {Name: "orders_2024"},
110 {Name: "orders_2025"},
111 },
112 }
113
114 tables, names := buildTablesMetadata(tableProto, nil, true)
115 a.Equal(3, len(tables))
116 a.ElementsMatch([]string{"orders", "orders_2024", "orders_2025"}, names)
117
118 // Verify that CreateIndex works on partition tables (was causing nil map panic)
119 for i, table := range tables {
120 index := &storepb.IndexMetadata{
121 Name: "idx_" + names[i] + "_created_at",
122 Expressions: []string{"created_at"},
123 Type: "btree",
124 }
125 err := table.CreateIndex(index)
126 a.NoError(err, "CreateIndex should not panic on table %s", names[i])
127 a.NotNil(table.GetIndex(index.Name), "Index should be retrievable after creation")
128 }
129}
130
131func TestSchemaMetadata_CreateTable(t *testing.T) {
132 metadata := &storepb.DatabaseSchemaMetadata{

Callers

nothing calls this directly

Calls 4

buildTablesMetadataFunction · 0.85
CreateIndexMethod · 0.80
EqualMethod · 0.65
GetIndexMethod · 0.45

Tested by

no test coverage detected