From 35270cf1e502226203589568871246628479b187 Mon Sep 17 00:00:00 2001 From: Nathan Villaescusa Date: Mon, 22 Apr 2024 12:48:48 -0700 Subject: [PATCH] Revert --- lib/sql/escape.go | 26 +++++++++++++------------- lib/sql/escape_test.go | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/sql/escape.go b/lib/sql/escape.go index f640e7e76..925de75dc 100644 --- a/lib/sql/escape.go +++ b/lib/sql/escape.go @@ -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 @@ -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) diff --git a/lib/sql/escape_test.go b/lib/sql/escape_test.go index e16473306..7b70201d6 100644 --- a/lib/sql/escape_test.go +++ b/lib/sql/escape_test.go @@ -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