Documentation ¶
Overview ¶
Package dbcommon provides common database functionality
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AllDBTypes []DBType
AllDBTypes is a list of all contract types. Since we use stringer and this is a testing library, instead of manually copying all these out we pull the names out of stringer. In order to make sure stringer is updated, we panic on any method called where the index is higher than the stringer array length.
Functions ¶
func GetGormLogger ¶
func GetGormLogger(zapLogger *log.ZapEventLogger) gormLogger.Interface
GetGormLogger gets a gorm logger at the correct level TODO investigate https://github.com/moul/zapgorm, we want to use the same write group.
Types ¶
type DBType ¶
type DBType int
DBType is the database driver to use.
func DBTypeFromString ¶
DBTypeFromString parses a database type from a string.
type Namer ¶
type Namer struct {
// contains filtered or unexported fields
}
Namer is used to pull consistent names for fields from models. This prevents inconsistency by panicing on breaking changes. It also allows us to avoid using xModelFieldName, yModelFieldName by taking advantage of introspection.
func (Namer) GetConsistentName ¶
GetConsistentName makes sure a `ColumnName` has a common column tag against all models we use this so we don't have to define bridgeRedeemModelFieldName, originChainFieldName, etc. panic's on an inconsistency. Note: this should only be called from init.
after this is called, you can safely call getGormFieldName(AnyModelWithField, fieldName) if all fields cannot make this guarantee, they should be separated out to avoid developer confusion.
this returns the result of getGormFieldName for a valid model. It also panics if no model is valid todo consider generating getters for all field names.