(c *Completer, databases, tables map[string]bool)
| 268 | } |
| 269 | |
| 270 | func (m CompletionMap) insertColumns(c *Completer, databases, tables map[string]bool) { |
| 271 | for database := range databases { |
| 272 | if len(database) == 0 { |
| 273 | for _, table := range c.cteTables { |
| 274 | if tables[table.Table] { |
| 275 | for _, column := range table.Columns { |
| 276 | m.Insert(base.Candidate{ |
| 277 | Type: base.CandidateTypeColumn, |
| 278 | Text: c.quotedIdentifierIfNeeded(column), |
| 279 | }) |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | continue |
| 284 | } |
| 285 | if _, exists := c.metadataCache[database]; !exists { |
| 286 | _, metadata, err := c.getMetadata(c.ctx, c.instanceID, database) |
| 287 | if err != nil || metadata == nil { |
| 288 | continue |
| 289 | } |
| 290 | c.metadataCache[database] = metadata |
| 291 | } |
| 292 | |
| 293 | for table := range tables { |
| 294 | tableMeta := c.metadataCache[database].GetSchemaMetadata("").GetTable(table) |
| 295 | if tableMeta == nil { |
| 296 | continue |
| 297 | } |
| 298 | for _, column := range tableMeta.GetProto().GetColumns() { |
| 299 | definition := fmt.Sprintf("%s | %s", table, column.Type) |
| 300 | if !column.Nullable { |
| 301 | definition += ", NOT NULL" |
| 302 | } |
| 303 | m.Insert(base.Candidate{ |
| 304 | Type: base.CandidateTypeColumn, |
| 305 | Text: c.quotedIdentifierIfNeeded(column.Name), |
| 306 | Definition: definition, |
| 307 | Comment: column.Comment, |
| 308 | }) |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | func (m CompletionMap) insertAllColumns(c *Completer) { |
| 315 | if _, exists := c.metadataCache[c.defaultDatabase]; !exists { |
no test coverage detected