Skip to content

feat: error message show field name #7452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025
Merged

feat: error message show field name #7452

merged 3 commits into from
May 21, 2025

Conversation

pi12138
Copy link
Contributor

@pi12138 pi12138 commented May 12, 2025

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

User Case Description

@@ -78,7 +78,7 @@ func (schema *Schema) parseRelation(field *Field) *Relationship {
cacheStore := schema.cacheStore

if relation.FieldSchema, err = getOrParse(fieldValue, cacheStore, schema.namer); err != nil {
schema.err = err
Copy link
Member

@jinzhu jinzhu May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change the error message to:

failed to parse field: %v, error: %w

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经根据建议修改,是否考虑为 schema.Field 添加 String() 方法

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不加吧,一般没有必要

@@ -78,7 +78,7 @@ func (schema *Schema) parseRelation(field *Field) *Relationship {
cacheStore := schema.cacheStore

if relation.FieldSchema, err = getOrParse(fieldValue, cacheStore, schema.namer); err != nil {
schema.err = fmt.Errorf("%w. The field name is %s", err, field.Name)
schema.err = fmt.Errorf("failed to parse field: %v, error: %w", field, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

field -> field.Name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@jinzhu jinzhu merged commit 1204330 into go-gorm:master May 21, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants