Support primary key have the capital letter
if use postgresql, eg:
```
//Model
type Model struct {
ID uint `gorm:"column:ID;primary_key"`
CreatedAt time.Time `gorm:"column:create_time"`
}
```
insert data error:
```
pq: column name "id" not found
```
This commit is contained in:
parent
6842b49a1a
commit
b051fb4901
@ -146,7 +146,7 @@ func forceReloadAfterCreateCallback(scope *Scope) {
|
||||
db := scope.DB().New().Table(scope.TableName()).Select(blankColumnsWithDefaultValue.([]string))
|
||||
for _, field := range scope.Fields() {
|
||||
if field.IsPrimaryKey && !field.IsBlank {
|
||||
db = db.Where(fmt.Sprintf("%v = ?", field.DBName), field.Field.Interface())
|
||||
db = db.Where(fmt.Sprintf("\"%v\" = ?", field.DBName), field.Field.Interface())
|
||||
}
|
||||
}
|
||||
db.Scan(scope.Value)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user