How to work with BIGSERIAL columns? There is no way of making them Optional
- Dominant language
- Go
- Stars
- 17.2k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Hey :-) I´ve researched a while now, but it seems i dont really get it. I have a column defined as BIGSERIAL. I dont want to set this value on `Create()` (since it should auto increment), so i want to make it `optional`.
```go
field.Int("insertion_order").
Optional().
SchemaType(map[string]string{
dialect.Postgres: postgres.TypeBigSerial,
}),
```
This results in an error:
`NOT NULL constraint is required for bigserial column`
If i remove the optional,. i am forced to set this value, which i dont want, since it should auto increment.
On the other hand, i´m also not able to make an custom auto increment, since i see no option of creating sequences.
There is just one line i have to remove from code generation, then the example (**without the optional**) above is working:
```go
if _, ok := pec.mutation.InsertionOrder(); !ok {
return &ValidationError{Name: "insertion_order", err: errors.New(`ent: missing required field "PendingEvent.insertion_order"`)}
}
```
Maybe there is someone who can give me some hints on how to work with such a case :-)
Contributor guide
Assessment
This issue has not been assessed yet.