Skip to content
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

entc/gen: block Optional on the ID field #2443

Merged
merged 3 commits into from Apr 2, 2022

Conversation

giautm
Copy link
Collaborator

@giautm giautm commented Apr 2, 2022

No description provided.

Comment on lines 26 to 31
_, err = NewType(&Config{Package: "entc/gen"}, &load.Schema{
Fields: []*load.Field{
{Unique: true, Default: true, Info: &field.TypeInfo{Type: field.TypeInt}},
{Name: "foo", Unique: true, Default: true, Info: &field.TypeInfo{Type: field.TypeInt}},
},
})
require.Error(err, "unique field can not have default")
require.EqualError(err, "unique field \"foo\" cannot have default value")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed the test to EqualError because the test was wrong, it just accept the field name cannot be empty error

Copy link
Member

@a8m a8m left a comment

Choose a reason for hiding this comment

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

💯

entc/gen/type.go Outdated Show resolved Hide resolved
entc/gen/type_test.go Outdated Show resolved Hide resolved
giautm and others added 2 commits April 3, 2022 00:30
Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
@a8m a8m merged commit 196875c into ent:master Apr 2, 2022
@a8m
Copy link
Member

a8m commented Apr 2, 2022

Thanks @giautm

@giautm giautm deleted the giautm-fix-id-optional branch April 2, 2022 21:31
gitlawr pushed a commit to gitlawr/ent that referenced this pull request Apr 13, 2022
* entc/gen: block Optional on the ID field

* chore: restore the old error message

* Update entc/gen/type.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
gitlawr pushed a commit to seal-io/ent that referenced this pull request Apr 13, 2022
* entc/gen: block Optional on the ID field

* chore: restore the old error message

* Update entc/gen/type.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
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.

None yet

2 participants