(t *testing.T)
| 96 | } |
| 97 | |
| 98 | func 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 | |
| 131 | func TestSchemaMetadata_CreateTable(t *testing.T) { |
| 132 | metadata := &storepb.DatabaseSchemaMetadata{ |
nothing calls this directly
no test coverage detected