db.Find(&Srt) raise error:
field XXX_NoUnkeyedLiteral: define a valid foreign key for relations or implement the Valuer/Scanner interface
HOW:add filter: field.Tag.Get("json") != "-"
WHY:unsupported parsing type: struct{} set guessLevel to guessEmbeddedHas
have been commented:schema/relationship.go:381
as follows:
reguessOrErr := func() {
switch cgl {
case guessGuess:
schema.guessRelation(relation, field, guessBelongs)
case guessBelongs:
schema.guessRelation(relation, field, guessEmbeddedBelongs)
case guessEmbeddedBelongs:
schema.guessRelation(relation, field, guessHas)
case guessHas:
schema.guessRelation(relation, field, guessEmbeddedHas)
// case guessEmbeddedHas:
default:
schema.err = fmt.Errorf("invalid field found for struct %v's field %s: define a valid foreign key for relations or implement the Valuer/Scanner interface", schema, field.Name)
}
}
* fixed belongs_to & has_one reversed if field same
* hasmany same foreign key bug fixed and test added
* belongsToSameForeignKey fixed and reverted old fix
* optimize gormSourceDir replace
* fmt.Errorf adjust and Optimize for-break
* strings trim
* feat: avoid using the same name field and if..else optimization adjustment
* optimization callbacks/create.go Create func if...else logic
* fix: callbacks/create.go Create func
* fix FileWithLineNum func and add gormSourceDir unit test
* remove debug print and utils_filenum_test.go
* for Config.cacheStore store PreparedStmtDB key
* invalid db error and value and invalid value length error (#4151)
* support named params in Select API (#4142)
* adds support for named arguments in select
* changes clause identifies and adds test
* optimize match english letters and midline
Co-authored-by: Ratan Phayade <ratanphayade@users.noreply.github.com>