go-gorm / sqlserver

GORM sqlserver driver
MIT License
56 stars 39 forks source link

Update create.go #39

Closed ru4sam326 closed 3 years ago

ru4sam326 commented 3 years ago

Getting error when it is checking for prioritized field, We have create composite primary key on a TableA and ID is unique which is foreign key in TableB. TableA has one to many with TableB, When were inserting with onconflict clause getting the below error.

panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x190 pc=0x7f4c07]

goroutine 368 [running]: testing.tRunner.func1.2(0xd7a900, 0x16261e0) /usr/local/go/src/testing/testing.go:1143 +0x332 testing.tRunner.func1(0xc0004e8a80) /usr/local/go/src/testing/testing.go:1146 +0x4b6 panic(0xd7a900, 0x16261e0) /usr/local/go/src/runtime/panic.go:965 +0x1b9 gorm.io/driver/sqlserver.Create(0xc000850090) /home/sambasiva/work/pkg/mod/gorm.io/driver/sqlserver@v1.0.9/create.go:135 +0x1087 gorm.io/gorm.(processor).Execute(0xc000896640, 0xc000850090, 0xe7cfcf) /home/sambasiva/work/pkg/mod/gorm.io/gorm@v1.21.14/callbacks.go:130 +0x3f5 gorm.io/gorm.(DB).Create(0xc000850090, 0xd08560, 0xc0008f34a0, 0x1) /home/sambasiva/work/pkg/mod/gorm.io/gorm@v1.21.14/finisher_api.go:24 +0xc5

What did this pull request do?

User Case Description

ru4sam326 commented 3 years ago

Without ID when we create a schema with other primary key and trying to insert with onconflict also getting above error