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)
| 84 | // NormalizeRow normalizes each value's type, as the tests only want to compare values. |
| 85 | // Returns a new row. |
| 86 | func NormalizeRow(fds []pgconn.FieldDescription, row sql.Row, normalize bool) sql.Row { |
| 87 | if len(row) == 0 { |
| 88 | return nil |
| 89 | } |
| 90 | newRow := make(sql.Row, len(row)) |
| 91 | for i := range row { |
| 92 | typ, ok := defaultMap.TypeForOID(fds[i].DataTypeOID) |
| 93 | if !ok { |
| 94 | panic(fmt.Sprintf("unknown oid: %v", fds[i].DataTypeOID)) |
| 95 | } |
| 96 | newRow[i] = NormalizeValToString(typ, row[i]) |
| 97 | if normalize { |
| 98 | newRow[i] = NormalizeIntsAndFloats(newRow[i]) |
| 99 | } |
| 100 | } |
| 101 | return newRow |
| 102 | } |
| 103 | |
| 104 | // NormalizeExpectedRow normalizes each value's type, as the tests only want to compare values. Returns a new row. |
| 105 | func NormalizeExpectedRow(fds []pgconn.FieldDescription, rows []sql.Row) []sql.Row { |
no test coverage detected