Fix warnings with schema Sync2 with default varchar as NVARCHAR #1783
|
@ -82,9 +82,7 @@ func (q Quoter) JoinWrite(b *strings.Builder, a []string, sep string) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
if s != "*" {
|
||||
q.QuoteTo(b, strings.TrimSpace(s))
|
||||
}
|
||||
q.QuoteTo(b, strings.TrimSpace(s))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -143,7 +141,7 @@ func (q Quoter) quoteWordTo(buf *strings.Builder, word string) error {
|
|||
}
|
||||
|
||||
isReserved := q.IsReserved(realWord)
|
||||
if isReserved {
|
||||
if isReserved && realWord != "*" {
|
||||
if err := buf.WriteByte(q.Prefix); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -151,7 +149,7 @@ func (q Quoter) quoteWordTo(buf *strings.Builder, word string) error {
|
|||
if _, err := buf.WriteString(realWord); err != nil {
|
||||
return err
|
||||
}
|
||||
if isReserved {
|
||||
if isReserved && realWord != "*" {
|
||||
return buf.WriteByte(q.Suffix)
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ func TestAlwaysQuoteTo(t *testing.T) {
|
|||
{"[mytable]", "`mytable`"},
|
||||
{"[mytable]", `[mytable]`},
|
||||
{`["mytable"]`, `"mytable"`},
|
||||
{`[mytable].*`, `[mytable].*`},
|
||||
{"[myschema].[mytable]", "myschema.mytable"},
|
||||
{"[myschema].[mytable]", "`myschema`.mytable"},
|
||||
{"[myschema].[mytable]", "myschema.`mytable`"},
|
||||
|
@ -65,6 +66,7 @@ func TestReversedQuoteTo(t *testing.T) {
|
|||
{"[mytable]", "mytable"},
|
||||
{"[mytable]", "`mytable`"},
|
||||
{"[mytable]", `[mytable]`},
|
||||
{"[mytable].*", `[mytable].*`},
|
||||
{`"mytable"`, `"mytable"`},
|
||||
{"myschema.[mytable]", "myschema.mytable"},
|
||||
{"myschema.[mytable]", "`myschema`.mytable"},
|
||||
|
@ -98,6 +100,7 @@ func TestNoQuoteTo(t *testing.T) {
|
|||
{"mytable", "mytable"},
|
||||
{"mytable", "`mytable`"},
|
||||
{"mytable", `[mytable]`},
|
||||
{"mytable.*", `[mytable].*`},
|
||||
{`"mytable"`, `"mytable"`},
|
||||
{"myschema.mytable", "myschema.mytable"},
|
||||
{"myschema.mytable", "`myschema`.mytable"},
|
||||
|
@ -127,6 +130,8 @@ func TestJoin(t *testing.T) {
|
|||
|
||||
assert.EqualValues(t, "[a],[b]", quoter.Join([]string{"a", " b"}, ","))
|
||||
|
||||
assert.EqualValues(t, "[a].*,[b].[c]", quoter.Join([]string{"a.*", " b.c"}, ","))
|
||||
|
||||
assert.EqualValues(t, "[f1], [f2], [f3]", quoter.Join(cols, ", "))
|
||||
|
||||
quoter.IsReserved = AlwaysNoReserve
|
||||
|
@ -134,11 +139,11 @@ func TestJoin(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStrings(t *testing.T) {
|
||||
cols := []string{"f1", "f2", "t3.f3"}
|
||||
cols := []string{"f1", "f2", "t3.f3", "t4.*"}
|
||||
quoter := Quoter{'[', ']', AlwaysReserve}
|
||||
|
||||
quotedCols := quoter.Strings(cols)
|
||||
assert.EqualValues(t, []string{"[f1]", "[f2]", "[t3].[f3]"}, quotedCols)
|
||||
assert.EqualValues(t, []string{"[f1]", "[f2]", "[t3].[f3]", "[t4].*"}, quotedCols)
|
||||
}
|
||||
|
||||
func TestTrim(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user