| 515 | } |
| 516 | |
| 517 | func buildSelectQuery(database, table, fields, partition, where, orderByClause string) string { |
| 518 | var query strings.Builder |
| 519 | query.WriteString("SELECT ") |
| 520 | if fields == "" { |
| 521 | // If all of the columns are generated, |
| 522 | // we need to make sure the query is valid. |
| 523 | fields = "''" |
| 524 | } |
| 525 | query.WriteString(fields) |
| 526 | query.WriteString(" FROM `") |
| 527 | query.WriteString(escapeString(database)) |
| 528 | query.WriteString("`.`") |
| 529 | query.WriteString(escapeString(table)) |
| 530 | query.WriteByte('`') |
| 531 | if partition != "" { |
| 532 | query.WriteString(" PARTITION(`") |
| 533 | query.WriteString(escapeString(partition)) |
| 534 | query.WriteString("`)") |
| 535 | } |
| 536 | |
| 537 | if where != "" { |
| 538 | query.WriteString(" ") |
| 539 | query.WriteString(where) |
| 540 | } |
| 541 | |
| 542 | if orderByClause != "" { |
| 543 | query.WriteString(" ") |
| 544 | query.WriteString(orderByClause) |
| 545 | } |
| 546 | |
| 547 | return query.String() |
| 548 | } |
| 549 | |
| 550 | func buildOrderByClause(tctx *tcontext.Context, conf *Config, db *BaseConn, database, table string, hasImplicitRowID bool) (string, error) { // revive:disable-line:flag-parameter |
| 551 | if !conf.SortByPk { |