Skip to content

Commit acd1537

Browse files
committed
Added comment for ParseSQLOutput
Signed-off-by: Lou Marvin Caraig <[email protected]>
1 parent 75779c2 commit acd1537

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cmdtests/common.go

+13
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,19 @@ func normalizeColName(s string) string {
287287
"-", "_", -1)
288288
}
289289

290+
// ParseSQLOutput parses a string into a `SQLOutputTable` in order to facilitate
291+
// comparisons between different results.
292+
// This has been introduced mainly for two different reasons:
293+
// 1. handling ordering of rows (assuming that in equality checks the order is
294+
// not important). This could be solved also by forcing the queries to have an
295+
// 'ORDER BY' clause.
296+
// 2. during the replacement of the SQL cli, there was a version using our custom
297+
// SQL cli and another using the MySQL one. In one case the headers were all
298+
// capitalized and in the other were not. Additionally, if the header is
299+
// composed by multiple words, the separator in one case is the space and in
300+
// the other is the dash. Moreover, in our SQL cli the newline was '\n' while on
301+
// MySQL is '\r\n'. This latter thing is also a minimal problem as we can simply
302+
// replace all the newlines of the buffer.
290303
func ParseSQLOutput(raw string) *SQLOutputTable {
291304
splitted := strings.Split(normalizeNewLine(raw), "\n")
292305
header := false

0 commit comments

Comments
 (0)