Your Question

If we wish to use a DBResolver for multiple Sources and multiple Replicas, do we need to provide a default dialector in the first gorm.Open() (to create a DB handle that the DBResolver will be registered to)?

The source code suggests that the dialector argument in gorm.Open() is optional, as it only assigns a Dialector if the input is not nil.

However, other parts of the source code require a default dialector, such as running an Exec() (source). If you try to do an Exec() without providing a dialector in the gorm.Open(), it panics with a nil pointer error.

The document you expected this should be explained

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

Expected answer

If there are multiple Sources, then the concept of a "default" shouldn't apply. Things that currently assume there's a default dialector should use the same logic as connection pools to select an appropriate dialector.