MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / formatSQLInternal

Function formatSQLInternal

pkg/mcp/tools.go:77–101  ·  view source on GitHub ↗

formatSQLInternal formats a SQL string using the provided options.

(sql string, indentSize int, uppercaseKeywords, addSemicolon bool)

Source from the content-addressed store, hash-verified

75
76// formatSQLInternal formats a SQL string using the provided options.
77func formatSQLInternal(sql string, indentSize int, uppercaseKeywords, addSemicolon bool) (map[string]any, error) {
78 if sql == "" {
79 return nil, fmt.Errorf("parameter 'sql' is required and must not be empty")
80 }
81
82 opts := gosqlx.FormatOptions{
83 IndentSize: indentSize,
84 UppercaseKeywords: uppercaseKeywords,
85 AddSemicolon: addSemicolon,
86 }
87
88 formatted, err := gosqlx.Format(sql, opts)
89 if err != nil {
90 return nil, fmt.Errorf("format failed: %w", err)
91 }
92
93 return map[string]any{
94 "formatted_sql": formatted,
95 "options": map[string]any{
96 "indent_size": indentSize,
97 "uppercase_keywords": uppercaseKeywords,
98 "add_semicolon": addSemicolon,
99 },
100 }, nil
101}
102
103// parseSQLInternal parses a SQL string and returns statement count and types.
104func parseSQLInternal(sql string) (map[string]any, error) {

Callers 5

handleFormatSQLFunction · 0.85
handleAnalyzeSQLFunction · 0.85

Calls 2

FormatFunction · 0.92
ErrorfMethod · 0.65