Skip to content

Commit

Permalink
Alias issue
Browse files Browse the repository at this point in the history
Trim spaces just to be more consistent
  • Loading branch information
fairking committed Apr 18, 2024
1 parent 7ea04ad commit e498e85
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions builder/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (b Buffer) escape_schema(table string) string {
}
return strings.Join(parts, ".")
} else {
return b.Quoter.ID(strings.ReplaceAll(table, ".", "_"))
return b.Quoter.ID(strings.ReplaceAll(strings.TrimSpace(table), ".", "_"))
}
}

Expand All @@ -147,9 +147,9 @@ func (b Buffer) escape(table, value string) string {
var escaped_table string
if table != "" {
if i := strings.Index(strings.ToLower(table), " as "); i > -1 {
escaped_table = b.escape_schema(table[:i]) + " AS " + b.Quoter.ID(table[i+4:])
escaped_table = b.escape_schema(table[:i]) + " AS " + b.Quoter.ID(strings.TrimSpace(table[i+4:]))
} else if i := strings.Index(strings.ToLower(table), " "); i > -1 {
escaped_table = b.escape_schema(table[:i]) + " " + b.Quoter.ID(table[i+1:])
escaped_table = b.escape_schema(table[:i]) + " " + b.Quoter.ID(strings.TrimSpace(table[i+1:]))
} else {
escaped_table = b.escape_schema(table)
}
Expand Down

0 comments on commit e498e85

Please sign in to comment.