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

Function FormatMistakeExample

pkg/errors/suggestions.go:445–452  ·  view source on GitHub ↗

FormatMistakeExample formats a MistakePattern into a human-readable multi-line block suitable for displaying in error messages, documentation, or interactive tutorials. The output includes the mistake name, the wrong SQL snippet, the corrected SQL snippet, and an explanation. Example output: Comm

(mistake MistakePattern)

Source from the content-addressed store, hash-verified

443// Right: SELECT dept, COUNT(*) FROM employees GROUP BY dept
444// Explanation: Non-aggregated columns in SELECT must appear in GROUP BY
445func FormatMistakeExample(mistake MistakePattern) string {
446 var sb strings.Builder
447 sb.WriteString(fmt.Sprintf("Common Mistake: %s\n", mistake.Name))
448 sb.WriteString(fmt.Sprintf(" ❌ Wrong: %s\n", mistake.Example))
449 sb.WriteString(fmt.Sprintf(" ✓ Right: %s\n", mistake.Correct))
450 sb.WriteString(fmt.Sprintf(" Explanation: %s\n", mistake.Explanation))
451 return sb.String()
452}
453
454// SuggestForWindowFunction provides targeted suggestions for window function syntax
455// errors. It inspects the SQL context to detect common mistakes such as a missing

Callers 2

mainFunction · 0.92
TestFormatMistakeExampleFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by 1

TestFormatMistakeExampleFunction · 0.68