NormalizeRow normalizes each value's type, as the tests only want to compare values. Returns a new row.
(fds []pgconn.FieldDescription, row sql.Row, normalize bool)
| 545 | // NormalizeRow normalizes each value's type, as the tests only want to compare values. |
| 546 | // Returns a new row. |
| 547 | func NormalizeRow(fds []pgconn.FieldDescription, row sql.Row, normalize bool) sql.Row { |
| 548 | if len(row) == 0 { |
| 549 | return nil |
| 550 | } |
| 551 | newRow := make(sql.Row, len(row)) |
| 552 | for i := range row { |
| 553 | dt, ok := types.IDToBuiltInDoltgresType[id.Type(id.Cache().ToInternal(fds[i].DataTypeOID))] |
| 554 | if !ok { |
| 555 | // try using text type |
| 556 | dt = types.Text |
| 557 | } |
| 558 | newRow[i] = NormalizeValToString(dt, row[i]) |
| 559 | if normalize { |
| 560 | newRow[i] = NormalizeIntsAndFloats(newRow[i]) |
| 561 | } |
| 562 | } |
| 563 | return newRow |
| 564 | } |
| 565 | |
| 566 | // NormalizeExpectedRow normalizes each value's type, as the tests only want to compare values. Returns a new row. |
| 567 | func NormalizeExpectedRow(fds []pgconn.FieldDescription, rows []sql.Row) []sql.Row { |
no test coverage detected