(metadata *storepb.DatabaseSchemaMetadata, filter *metadataFilter, limit int)
| 8 | ) |
| 9 | |
| 10 | func convertStoreDatabaseMetadata(metadata *storepb.DatabaseSchemaMetadata, filter *metadataFilter, limit int) *v1pb.DatabaseMetadata { |
| 11 | m := &v1pb.DatabaseMetadata{ |
| 12 | CharacterSet: metadata.CharacterSet, |
| 13 | Collation: metadata.Collation, |
| 14 | Owner: metadata.Owner, |
| 15 | } |
| 16 | |
| 17 | for _, schema := range metadata.Schemas { |
| 18 | if schema == nil { |
| 19 | continue |
| 20 | } |
| 21 | if filter != nil && filter.schema != nil { |
| 22 | if schema.Name != *filter.schema { |
| 23 | continue |
| 24 | } |
| 25 | } |
| 26 | s := &v1pb.SchemaMetadata{ |
| 27 | Name: schema.Name, |
| 28 | Owner: schema.Owner, |
| 29 | Comment: schema.Comment, |
| 30 | SkipDump: schema.SkipDump, |
| 31 | } |
| 32 | for _, table := range schema.Tables { |
| 33 | if table == nil { |
| 34 | continue |
| 35 | } |
| 36 | if filter != nil && filter.table != nil { |
| 37 | if !filter.table.wildcard { |
| 38 | if table.Name != filter.table.name { |
| 39 | continue |
| 40 | } |
| 41 | } else { |
| 42 | if !strings.Contains(strings.ToLower(table.Name), filter.table.name) { |
| 43 | continue |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | s.Tables = append(s.Tables, convertStoreTableMetadata(table)) |
| 48 | if limit > 0 && len(s.Tables) >= limit { |
| 49 | break |
| 50 | } |
| 51 | } |
| 52 | for _, externalTable := range schema.ExternalTables { |
| 53 | if externalTable == nil { |
| 54 | continue |
| 55 | } |
| 56 | s.ExternalTables = append(s.ExternalTables, convertStoreExternalTableMetadata(externalTable)) |
| 57 | } |
| 58 | // Only return table for request with a filter. |
| 59 | if filter != nil { |
| 60 | m.Schemas = append(m.Schemas, s) |
| 61 | continue |
| 62 | } |
| 63 | |
| 64 | for _, view := range schema.Views { |
| 65 | if view == nil { |
| 66 | continue |
| 67 | } |
no test coverage detected