mirror of https://github.com/go-gorm/gorm.git
Ignore unexported field
This commit is contained in:
parent
0c4e43cd7a
commit
215b736fe1
4
model.go
4
model.go
|
@ -3,10 +3,10 @@ package gorm
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go/ast"
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ func (m *Model) fields(operation string) (fields []Field) {
|
||||||
|
|
||||||
for i := 0; i < typ.NumField(); i++ {
|
for i := 0; i < typ.NumField(); i++ {
|
||||||
p := typ.Field(i)
|
p := typ.Field(i)
|
||||||
if !p.Anonymous {
|
if !p.Anonymous && ast.IsExported(p.Name) {
|
||||||
var field Field
|
var field Field
|
||||||
field.Name = p.Name
|
field.Name = p.Name
|
||||||
field.DbName = toSnake(p.Name)
|
field.DbName = toSnake(p.Name)
|
||||||
|
|
Loading…
Reference in New Issue