Your Question

I am trying to create records using the Gorm CreateInBatches method. I do not want to fail the complete batch operation if there is any conflict so I am using the gorm clause to ignore conflicts, but I am unable to get failed records with this approach. Is there a way to get the failed records when using batching with ignore clause in Gorm?

code: result = gormDbClient.Clauses(clause.OnConflict{DoNothing: true}).CreateInBatches(users, 500)

The document you expected this should be explained

Expected answer

Comment From: a631807682

The success and failure of gorm depends on the database return. When the ON CONFLICT clause is used, the execution of the sql statement is actually successful, so it will not be regarded as a failure record. Of course, you can implement your own CreateInBatches function refer to https://github.com/go-gorm/gorm/blob/master/finisher_api.go#L28