1 Star 1 Fork 0

bigbase/pg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
append_field.go 953 Bytes
一键复制 编辑 原始数据 按行查看 历史
Vladimir Mihailenco 提交于 2017-05-08 15:38 . Fix channel name quotting
package types
import "github.com/go-pg/pg/internal/parser"
func AppendField(b []byte, field string, quote int) []byte {
return appendField(b, parser.NewString(field), quote)
}
func AppendFieldBytes(b []byte, field []byte, quote int) []byte {
return appendField(b, parser.New(field), quote)
}
func appendField(b []byte, p *parser.Parser, quote int) []byte {
var quoted bool
for p.Valid() {
c := p.Read()
switch c {
case '*':
if !quoted {
b = append(b, '*')
continue
}
case '.':
if quoted && quote == 1 {
b = append(b, '"')
quoted = false
}
b = append(b, '.')
if p.Skip('*') {
b = append(b, '*')
} else if quote == 1 {
b = append(b, '"')
quoted = true
}
continue
}
if !quoted && quote == 1 {
b = append(b, '"')
quoted = true
}
if c == '"' {
b = append(b, '"', '"')
} else {
b = append(b, c)
}
}
if quoted && quote == 1 {
b = append(b, '"')
}
return b
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/bigbase/pg.git
git@gitee.com:bigbase/pg.git
bigbase
pg
pg
v7.1.6

搜索帮助