(c *Completer)
| 453 | } |
| 454 | |
| 455 | func (m CompletionMap) insertAllColumns(c *Completer) { |
| 456 | if _, exists := c.metadataCache[c.defaultDatabase]; !exists { |
| 457 | _, metadata, err := c.getMetadata(c.ctx, c.instanceID, c.defaultDatabase) |
| 458 | if err != nil || metadata == nil { |
| 459 | return |
| 460 | } |
| 461 | c.metadataCache[c.defaultDatabase] = metadata |
| 462 | } |
| 463 | |
| 464 | metadata := c.metadataCache[c.defaultDatabase] |
| 465 | for _, schema := range metadata.ListSchemaNames() { |
| 466 | schemaMeta := metadata.GetSchemaMetadata(schema) |
| 467 | if schemaMeta == nil { |
| 468 | continue |
| 469 | } |
| 470 | for _, table := range schemaMeta.ListTableNames() { |
| 471 | tableMeta := schemaMeta.GetTable(table) |
| 472 | if tableMeta == nil { |
| 473 | continue |
| 474 | } |
| 475 | for _, column := range tableMeta.GetProto().GetColumns() { |
| 476 | definition := fmt.Sprintf("%s.%s | %s", schema, table, column.Type) |
| 477 | if !column.Nullable { |
| 478 | definition += ", NOT NULL" |
| 479 | } |
| 480 | m.Insert(base.Candidate{ |
| 481 | Type: base.CandidateTypeColumn, |
| 482 | Text: c.quotedIdentifierIfNeeded(column.Name), |
| 483 | Definition: definition, |
| 484 | Comment: column.Comment, |
| 485 | }) |
| 486 | } |
| 487 | } |
| 488 | for _, ft := range schemaMeta.ListForeignTableNames() { |
| 489 | extMeta := schemaMeta.GetExternalTable(ft) |
| 490 | if extMeta == nil { |
| 491 | continue |
| 492 | } |
| 493 | for _, column := range extMeta.GetProto().GetColumns() { |
| 494 | definition := fmt.Sprintf("%s.%s | %s", schema, ft, column.Type) |
| 495 | if !column.Nullable { |
| 496 | definition += ", NOT NULL" |
| 497 | } |
| 498 | m.Insert(base.Candidate{ |
| 499 | Type: base.CandidateTypeColumn, |
| 500 | Text: c.quotedIdentifierIfNeeded(column.Name), |
| 501 | Definition: definition, |
| 502 | Comment: column.Comment, |
| 503 | }) |
| 504 | } |
| 505 | } |
| 506 | for _, mv := range schemaMeta.ListMaterializedViewNames() { |
| 507 | mvMeta := schemaMeta.GetMaterializedView(mv) |
| 508 | if mvMeta == nil { |
| 509 | continue |
| 510 | } |
| 511 | if columns, err := c.resolveMaterializedViewColumns(mvMeta.GetDefinition(), schema, mv); err == nil { |
| 512 | for _, col := range columns { |
no test coverage detected