Skip to content

Commit

Permalink
replace multiple white space
Browse files Browse the repository at this point in the history
  • Loading branch information
mazrean committed Nov 30, 2024
1 parent 3e26cf5 commit a43f15c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions dbdoc/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ func extractSubQueries(_ *Context, sql string) []string {

func analyzeSQLWithoutSubQuery(ctx *Context, sqlValue string, pos token.Pos) []Query {
sqlValue = strings.TrimLeftFunc(sqlValue, unicode.IsSpace)
sqlValue = strings.TrimFunc(sqlValue, func(r rune) bool {
return r == '\n' || r == '\r'
})
sqlValue = replaceMultipleWhitespace(sqlValue)

var queries []Query
switch {
Expand Down Expand Up @@ -217,6 +215,11 @@ func analyzeSQLWithoutSubQuery(ctx *Context, sqlValue string, pos token.Pos) []Q
return queries
}

func replaceMultipleWhitespace(s string) string {
fields := strings.Fields(s)
return strings.Join(fields, " ")
}

func tableForm(ctx *Context, sqlValue string, pos token.Pos) []string {
position := ctx.FileSet.Position(pos)
filename, err := filepath.Rel(ctx.WorkDir, position.Filename)
Expand Down
Binary file added isucrud
Binary file not shown.

0 comments on commit a43f15c

Please sign in to comment.