Add BuildLiteralSQL and QueryExplain functions#25
Conversation
e53b746 to
a94b176
Compare
| // the preparableExpression interface for custom types, and finally returns the input | ||
| // as-is when neither applies. | ||
| func toNonPreparedExpression(sqlExpression exp.SQLExpression) exp.SQLExpression { | ||
| switch e := sqlExpression.(type) { |
There was a problem hiding this comment.
Do we really need this type-assertion switch? why sqlExpression.(preparableExpression) is not enough?
There was a problem hiding this comment.
Unfortunately, Datasets have different return types
func (d *SelectDataset) Prepared(prepared bool) *SelectDataset
func (d *InsertDataset) Prepared(prepared bool) *InsertDataset
...
so the sqlExpression.(preparableExpression) will not work for them.
| } | ||
| } | ||
|
|
||
| sep := "+" |
There was a problem hiding this comment.
Suggest using strings.Builder for constructing separator as well with the pre-calculated capacity to avoid unnecessary memory allocations
| return runExplainString(q, sqlExpression, "EXPLAIN QUERY PLAN") | ||
| } | ||
|
|
||
| func runExplain(q Querier, sqlExpression exp.SQLExpression, prefix string) ([][]string, error) { |
There was a problem hiding this comment.
runExplain and runExplainString are almost the same. Did you consider an option to return calls from the runExplain and call it within runExplainString?
| return row, nil | ||
| } | ||
|
|
||
| func formatTable(data [][]string) string { |
There was a problem hiding this comment.
there are no unit tests for checking the table presentation, right? suggest adding them
a94b176 to
91660d3
Compare
91660d3 to
a6cbba9
Compare
No description provided.