diff --git a/internal/jet/sql_builder.go b/internal/jet/sql_builder.go index 7077af4..8764dd7 100644 --- a/internal/jet/sql_builder.go +++ b/internal/jet/sql_builder.go @@ -4,15 +4,16 @@ import ( "bytes" "database/sql/driver" "fmt" - "github.com/go-jet/jet/v2/internal/3rdparty/pq" - "github.com/go-jet/jet/v2/internal/utils/is" - "github.com/google/uuid" "reflect" "sort" "strconv" "strings" "time" "unicode" + + "github.com/go-jet/jet/v2/internal/3rdparty/pq" + "github.com/go-jet/jet/v2/internal/utils/is" + "github.com/google/uuid" ) // SQLBuilder generates output SQL @@ -309,8 +310,8 @@ func shouldQuoteIdentifier(identifier string) bool { } // check if contains non ascii characters - for _, c := range identifier { - if unicode.IsNumber(c) || c == '_' { + for i, c := range identifier { + if (unicode.IsNumber(c) && i > 0) || c == '_' { continue } if c > unicode.MaxASCII || !unicode.IsLetter(c) || unicode.IsUpper(c) { diff --git a/internal/jet/sql_builder_test.go b/internal/jet/sql_builder_test.go index ebcf83f..fc6e326 100644 --- a/internal/jet/sql_builder_test.go +++ b/internal/jet/sql_builder_test.go @@ -1,10 +1,11 @@ package jet import ( - "github.com/google/uuid" - "github.com/stretchr/testify/require" "testing" "time" + + "github.com/google/uuid" + "github.com/stretchr/testify/require" ) func TestArgToString(t *testing.T) { @@ -58,4 +59,5 @@ func TestShouldQuote(t *testing.T) { require.Equal(t, shouldQuoteIdentifier("abc_123"), false) require.Equal(t, shouldQuoteIdentifier("Abc_123"), true) require.Equal(t, shouldQuoteIdentifier("DŽƜĐǶ"), true) + require.Equal(t, shouldQuoteIdentifier("1test"), true) }