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

autoIncrementIncrement not work in postgres #756

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sasakiyori
Copy link

@sasakiyori sasakiyori commented Aug 20, 2024

Explain your user case and expected results

type Book struct {
	BookID int    `gorm:"column:book_id;autoIncrement:true;autoIncrementIncrement:10"`
	Name   string `gorm:"column:name;type:varchar(255)"`
}
GORM_DIALECT=postgres go test

Whether autoIncrementIncrement is set or not, the increment step is always 1.

2024/08/20 16:54:05 testing postgres...

2024/08/20 16:54:05 /Users/sasakiyori/go/pkg/mod/gorm.io/driver/[email protected]/migrator.go:186
[0.348ms] [rows:1] SELECT count(*) FROM information_schema.tables WHERE table_schema = CURRENT_SCHEMA() AND table_name = 'books' AND table_type = 'BASE TABLE'

2024/08/20 16:54:05 /Users/sasakiyori/go/pkg/mod/gorm.io/driver/[email protected]/migrator.go:157
[1.049ms] [rows:0] CREATE TABLE "books" ("book_id" bigserial,"name" varchar(255))

2024/08/20 16:54:05 /Users/sasakiyori/gitcode/playground/main_test.go:23
[1.291ms] [rows:1] select increment from information_schema.sequences where sequence_name = 'books_book_id_seq'
--- FAIL: TestGORM (0.00s)
    main_test.go:30: auto increment should be 10, but get 1
FAIL
exit status 1
FAIL    gorm.io/playground      0.688s

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.

1 participant