Support restoring sql with comments
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
```go
func RestoreCTX() (*format.RestoreCtx, *strings.Builder) {
var s strings.Builder
return format.NewRestoreCtx(format.RestoreStringSingleQuotes|
format.RestoreKeyWordLowercase|
format.RestoreNameBackQuotes|
format.RestoreTiDBSpecialComment, &s), &s
}
func TestComment(t *testing.T) {
tcs := []string{
`SELECT /* this is an in-line comment */ 1 + 1`,
}
for _, tc := range tcs {
node, err := Parse(tc, "", "")
if err != nil {
t.Log(err)
return
}
ctx, s := RestoreCTX()
if err := node.Restore(ctx); err != nil {
t.Log(err)
return
}
t.Log(s.String())
}
}
```
I expect to print `select /* this is an in-line comment */ 1 + 1`, but it prints `select 1+1`。
Contributor guide
Assessment
This issue has not been assessed yet.