(app App, tables []identifier)
| 485 | } |
| 486 | |
| 487 | func findCollectionsByIdentifiers(app App, tables []identifier) (map[string]*Collection, error) { |
| 488 | names := make([]any, 0, len(tables)) |
| 489 | |
| 490 | for _, table := range tables { |
| 491 | if strings.Contains(table.alias, "(") { |
| 492 | continue // skip expressions |
| 493 | } |
| 494 | names = append(names, table.original) |
| 495 | } |
| 496 | |
| 497 | if len(names) == 0 { |
| 498 | return nil, nil |
| 499 | } |
| 500 | |
| 501 | result := make(map[string]*Collection, len(names)) |
| 502 | collections := make([]*Collection, 0, len(names)) |
| 503 | |
| 504 | err := app.CollectionQuery(). |
| 505 | AndWhere(dbx.In("name", names...)). |
| 506 | All(&collections) |
| 507 | if err != nil { |
| 508 | return nil, err |
| 509 | } |
| 510 | |
| 511 | for _, table := range tables { |
| 512 | for _, collection := range collections { |
| 513 | if collection.Name == table.original { |
| 514 | result[table.alias] = collection |
| 515 | } |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | return result, nil |
| 520 | } |
| 521 | |
| 522 | func getQueryTableInfo(app App, selectQuery string) ([]*TableInfoRow, error) { |
| 523 | tempView := "_temp_" + security.PseudorandomString(6) |
no test coverage detected
searching dependent graphs…