Skip to content

Commit

Permalink
Allow disable returning from dialector config, close #88
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Oct 8, 2022
1 parent 0d0e3a2 commit d3403e4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ var timeZoneMatcher = regexp.MustCompile("(time_zone|TimeZone)=(.*?)($|&| )")

func (dialector Dialector) Initialize(db *gorm.DB) (err error) {
// register callbacks
callbacks.RegisterDefaultCallbacks(db, &callbacks.Config{
CreateClauses: []string{"INSERT", "VALUES", "ON CONFLICT", "RETURNING"},
UpdateClauses: []string{"UPDATE", "SET", "WHERE", "RETURNING"},
DeleteClauses: []string{"DELETE", "FROM", "WHERE", "RETURNING"},
})
if !dialector.WithoutReturning {
callbacks.RegisterDefaultCallbacks(db, &callbacks.Config{
CreateClauses: []string{"INSERT", "VALUES", "ON CONFLICT", "RETURNING"},
UpdateClauses: []string{"UPDATE", "SET", "WHERE", "RETURNING"},
DeleteClauses: []string{"DELETE", "FROM", "WHERE", "RETURNING"},
})
}

if dialector.Conn != nil {
db.ConnPool = dialector.Conn
Expand Down

0 comments on commit d3403e4

Please sign in to comment.