go-gorm / dbresolver

Multiple databases, read-write splitting FOR GORM

Home Page:https://gorm.io/docs/dbresolver.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updating from v1.1.0 to v1.2.0 may cause "runtime error: invalid memory address or nil pointer dereference"

mgsweet opened this issue · comments

GORM Playground Link

Description

Updating from v1.1.0 to v1.2.0 may cause panic because of the following line:

stmt.DB.Callback().Query().Get("gorm:db_resolver")(stmt.DB)

Get("gorm:db_resolver") would return nil if db_resolver is not set up correctly, which would cause "runtime error: invalid memory address or nil pointer dereference".

Fixed that.