names with upper charactor on postgres will need quotes

This commit is contained in:
Lunny Xiao 2020-03-06 15:28:29 +08:00
parent 717aabf022
commit e86b5375a5
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 13 additions and 1 deletions

View File

@ -788,6 +788,18 @@ func (db *postgres) Init(d *core.DB, uri *URI) error {
return nil
}
func (db *postgres) needQuote(name string) bool {
if db.IsReserved(name) {
return true
}
for _, c := range name {
if c >= 'A' && c <= 'Z' {
return true
}
}
return false
}
func (db *postgres) SetQuotePolicy(quotePolicy QuotePolicy) {
switch quotePolicy {
case QuotePolicyNone:
@ -796,7 +808,7 @@ func (db *postgres) SetQuotePolicy(quotePolicy QuotePolicy) {
db.quoter = q
case QuotePolicyReserved:
var q = postgresQuoter
q.IsReserved = db.IsReserved
q.IsReserved = db.needQuote
db.quoter = q
case QuotePolicyAlways:
fallthrough