Skip to content

Add BuildLiteralSQL and QueryExplain functions#25

Merged
vasayxtx merged 1 commit into
acronis:mainfrom
GrayDragon82:add_literal_sql_adn_explain_functions
Apr 30, 2026
Merged

Add BuildLiteralSQL and QueryExplain functions#25
vasayxtx merged 1 commit into
acronis:mainfrom
GrayDragon82:add_literal_sql_adn_explain_functions

Conversation

@GrayDragon82
Copy link
Copy Markdown

No description provided.

@GrayDragon82 GrayDragon82 requested a review from vasayxtx as a code owner April 29, 2026 09:02
@GrayDragon82 GrayDragon82 force-pushed the add_literal_sql_adn_explain_functions branch from e53b746 to a94b176 Compare April 29, 2026 13:09
Comment thread goquutil/query.go
// 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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this type-assertion switch? why sqlExpression.(preparableExpression) is not enough?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread goquutil/query.go Outdated
}
}

sep := "+"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest using strings.Builder for constructing separator as well with the pre-calculated capacity to avoid unnecessary memory allocations

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread goquutil/query.go
return runExplainString(q, sqlExpression, "EXPLAIN QUERY PLAN")
}

func runExplain(q Querier, sqlExpression exp.SQLExpression, prefix string) ([][]string, error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runExplain and runExplainString are almost the same. Did you consider an option to return calls from the runExplain and call it within runExplainString?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread goquutil/query.go
return row, nil
}

func formatTable(data [][]string) string {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are no unit tests for checking the table presentation, right? suggest adding them

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@GrayDragon82 GrayDragon82 force-pushed the add_literal_sql_adn_explain_functions branch from a94b176 to 91660d3 Compare April 30, 2026 09:52
@GrayDragon82 GrayDragon82 force-pushed the add_literal_sql_adn_explain_functions branch from 91660d3 to a6cbba9 Compare April 30, 2026 12:42
@vasayxtx vasayxtx merged commit 67e5c22 into acronis:main Apr 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants