Fix oid index for postgres (#2154)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2154
This commit is contained in:
parent
f9a6990ecb
commit
c98930f8f2
|
@ -862,11 +862,11 @@ func (db *postgres) needQuote(name string) bool {
|
||||||
func (db *postgres) SetQuotePolicy(quotePolicy QuotePolicy) {
|
func (db *postgres) SetQuotePolicy(quotePolicy QuotePolicy) {
|
||||||
switch quotePolicy {
|
switch quotePolicy {
|
||||||
case QuotePolicyNone:
|
case QuotePolicyNone:
|
||||||
var q = postgresQuoter
|
q := postgresQuoter
|
||||||
q.IsReserved = schemas.AlwaysNoReserve
|
q.IsReserved = schemas.AlwaysNoReserve
|
||||||
db.quoter = q
|
db.quoter = q
|
||||||
case QuotePolicyReserved:
|
case QuotePolicyReserved:
|
||||||
var q = postgresQuoter
|
q := postgresQuoter
|
||||||
q.IsReserved = db.needQuote
|
q.IsReserved = db.needQuote
|
||||||
db.quoter = q
|
db.quoter = q
|
||||||
case QuotePolicyAlways:
|
case QuotePolicyAlways:
|
||||||
|
@ -1125,7 +1125,7 @@ WHERE n.nspname= s.table_schema AND c.relkind = 'r'::char AND c.relname = $1%s A
|
||||||
col.Name = strings.Trim(colName, `" `)
|
col.Name = strings.Trim(colName, `" `)
|
||||||
|
|
||||||
if colDefault != nil {
|
if colDefault != nil {
|
||||||
var theDefault = *colDefault
|
theDefault := *colDefault
|
||||||
// cockroach has type with the default value with :::
|
// cockroach has type with the default value with :::
|
||||||
// and postgres with ::, we should remove them before store them
|
// and postgres with ::, we should remove them before store them
|
||||||
idx := strings.Index(theDefault, ":::")
|
idx := strings.Index(theDefault, ":::")
|
||||||
|
@ -1301,15 +1301,8 @@ func (db *postgres) GetIndexes(queryer core.Queryer, ctx context.Context, tableN
|
||||||
}
|
}
|
||||||
colNames = getIndexColName(indexdef)
|
colNames = getIndexColName(indexdef)
|
||||||
|
|
||||||
isSkip := false
|
// Oid It's a special index. You can't put it in. TODO: This is not perfect.
|
||||||
//Oid It's a special index. You can't put it in
|
if indexName == tableName+"_oid_index" && len(colNames) == 1 && colNames[0] == "oid" {
|
||||||
for _, element := range colNames {
|
|
||||||
if "oid" == element {
|
|
||||||
isSkip = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if isSkip {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue