Skip to content

Commit

Permalink
Revert
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-artie committed Apr 22, 2024
1 parent 6fb52c7 commit 35270cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions lib/sql/escape.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@ type NameArgs struct {
// symbolsToEscape are additional keywords that we need to escape
var symbolsToEscape = []string{":"}

func needsEscaping(name string, uppercaseEscNames bool, destKind constants.DestinationKind) bool {
func EscapeNameIfNecessary(name string, uppercaseEscNames bool, args *NameArgs) string {
if args == nil || !args.Escape {
return name
}

if needsEscaping(name, args.DestKind) {
return escapeName(name, uppercaseEscNames, args.DestKind)
}

return name
}

func needsEscaping(name string, destKind constants.DestinationKind) bool {
var reservedKeywords []string
if destKind == constants.Redshift {
reservedKeywords = constants.RedshiftReservedKeywords
Expand Down Expand Up @@ -49,18 +61,6 @@ func needsEscaping(name string, uppercaseEscNames bool, destKind constants.Desti
return needsEscaping
}

func EscapeNameIfNecessary(name string, uppercaseEscNames bool, args *NameArgs) string {
if args == nil || !args.Escape {
return name
}

if needsEscaping(name, uppercaseEscNames, args.DestKind) {
return escapeName(name, uppercaseEscNames, args.DestKind)
}

return name
}

func escapeName(name string, uppercaseEscNames bool, destKind constants.DestinationKind) string {
if uppercaseEscNames {
name = strings.ToUpper(name)
Expand Down
2 changes: 1 addition & 1 deletion lib/sql/escape_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestEscapeName(t *testing.T) {
func TestEscapeNameIfNecessary(t *testing.T) {
type _testCase struct {
name string
nameToEscape string
Expand Down

0 comments on commit 35270cf

Please sign in to comment.