sqlmanager

package
v0.4.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2024 License: MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	PostgresDriver = "postgres"
	MysqlDriver    = "mysql"
)
View Source
const (
	DisableForeignKeyChecks = "SET FOREIGN_KEY_CHECKS = 0;"
)

Variables

This section is empty.

Functions

func BuildMysqlTruncateStatement

func BuildMysqlTruncateStatement(
	schema string,
	table string,
) (string, error)

func BuildPgTruncateCascadeStatement

func BuildPgTruncateCascadeStatement(
	schema string,
	table string,
) (string, error)

func BuildPgTruncateStatement

func BuildPgTruncateStatement(
	tables []string,
) string

func BuildTable

func BuildTable(schema, table string) string

func EscapeMysqlColumn

func EscapeMysqlColumn(col string) string

func EscapeMysqlColumns

func EscapeMysqlColumns(cols []string) []string

func EscapePgColumn

func EscapePgColumn(col string) string

func EscapePgColumns

func EscapePgColumns(cols []string) []string

func GetUniqueSchemaColMappings added in v0.4.24

func GetUniqueSchemaColMappings(
	schemas []*DatabaseSchemaRow,
) map[string]map[string]*ColumnInfo

func Ptr

func Ptr[T any](val T) *T

Types

type AlterTableStatement added in v0.4.24

type AlterTableStatement struct {
	Statement      string
	ConstraintType ConstraintType
}

type BatchExecOpts

type BatchExecOpts struct {
	Prefix *string // this string will be added to the start of each statement
}

type ColumnInfo

type ColumnInfo struct {
	OrdinalPosition        int32  // Specifies the sequence or order in which each column is defined within the table. Starts at 1 for the first column.
	ColumnDefault          string // Specifies the default value for a column, if any is set.
	IsNullable             bool   // Specifies if the column is nullable or not.
	DataType               string // Specifies the data type of the column, i.e., bool, varchar, int, etc.
	CharacterMaximumLength *int32 // Specifies the maximum allowable length of the column for character-based data types. For datatypes such as integers, boolean, dates etc. this is NULL.
	NumericPrecision       *int32 // Specifies the precision for numeric data types. It represents the TOTAL count of significant digits in the whole number, that is, the number of digits to BOTH sides of the decimal point. Null for non-numeric data types.
	NumericScale           *int32 // Specifies the scale of the column for numeric data types, specifically non-integers. It represents the number of digits to the RIGHT of the decimal point. Null for non-numeric data types and integers.
}

type ConstraintType added in v0.4.24

type ConstraintType int
const (
	PrimaryConstraintType ConstraintType = iota
	ForeignConstraintType
	UniqueConstraintType
	CheckConstraintType
)

type DatabaseSchemaRow

type DatabaseSchemaRow struct {
	TableSchema            string
	TableName              string
	ColumnName             string
	DataType               string
	ColumnDefault          string
	IsNullable             string
	CharacterMaximumLength int32
	NumericPrecision       int32
	NumericScale           int32
	OrdinalPosition        int16
	GeneratedType          *string
}

type ForeignConstraint

type ForeignConstraint struct {
	Columns     []string
	NotNullable []bool
	ForeignKey  *ForeignKey
}

type ForeignKey

type ForeignKey struct {
	Table   string
	Columns []string
}

type ForeignKeyConstraintsRow

type ForeignKeyConstraintsRow struct {
	ConstraintName    string
	SchemaName        string
	TableName         string
	ColumnName        string
	IsNullable        bool
	ForeignSchemaName string
	ForeignTableName  string
	ForeignColumnName string
}

type MockSqlDatabase

type MockSqlDatabase struct {
	mock.Mock
}

MockSqlDatabase is an autogenerated mock type for the SqlDatabase type

func NewMockSqlDatabase

func NewMockSqlDatabase(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockSqlDatabase

NewMockSqlDatabase creates a new instance of MockSqlDatabase. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockSqlDatabase) BatchExec

func (_m *MockSqlDatabase) BatchExec(ctx context.Context, batchSize int, statements []string, opts *BatchExecOpts) error

BatchExec provides a mock function with given fields: ctx, batchSize, statements, opts

func (*MockSqlDatabase) Close

func (_m *MockSqlDatabase) Close()

Close provides a mock function with given fields:

func (*MockSqlDatabase) EXPECT

func (*MockSqlDatabase) Exec

func (_m *MockSqlDatabase) Exec(ctx context.Context, statement string) error

Exec provides a mock function with given fields: ctx, statement

func (*MockSqlDatabase) GetCreateTableStatement

func (_m *MockSqlDatabase) GetCreateTableStatement(ctx context.Context, schema string, table string) (string, error)

GetCreateTableStatement provides a mock function with given fields: ctx, schema, table

func (*MockSqlDatabase) GetDatabaseSchema

func (_m *MockSqlDatabase) GetDatabaseSchema(ctx context.Context) ([]*DatabaseSchemaRow, error)

GetDatabaseSchema provides a mock function with given fields: ctx

func (*MockSqlDatabase) GetForeignKeyConstraints

func (_m *MockSqlDatabase) GetForeignKeyConstraints(ctx context.Context, schemas []string) ([]*ForeignKeyConstraintsRow, error)

GetForeignKeyConstraints provides a mock function with given fields: ctx, schemas

func (*MockSqlDatabase) GetForeignKeyConstraintsMap

func (_m *MockSqlDatabase) GetForeignKeyConstraintsMap(ctx context.Context, schemas []string) (map[string][]*ForeignConstraint, error)

GetForeignKeyConstraintsMap provides a mock function with given fields: ctx, schemas

func (*MockSqlDatabase) GetPrimaryKeyConstraints

func (_m *MockSqlDatabase) GetPrimaryKeyConstraints(ctx context.Context, schemas []string) ([]*PrimaryKey, error)

GetPrimaryKeyConstraints provides a mock function with given fields: ctx, schemas

func (*MockSqlDatabase) GetPrimaryKeyConstraintsMap

func (_m *MockSqlDatabase) GetPrimaryKeyConstraintsMap(ctx context.Context, schemas []string) (map[string][]string, error)

GetPrimaryKeyConstraintsMap provides a mock function with given fields: ctx, schemas

func (*MockSqlDatabase) GetRolePermissionsMap

func (_m *MockSqlDatabase) GetRolePermissionsMap(ctx context.Context, role string) (map[string][]string, error)

GetRolePermissionsMap provides a mock function with given fields: ctx, role

func (*MockSqlDatabase) GetSchemaColumnMap

func (_m *MockSqlDatabase) GetSchemaColumnMap(ctx context.Context) (map[string]map[string]*ColumnInfo, error)

GetSchemaColumnMap provides a mock function with given fields: ctx

func (*MockSqlDatabase) GetTableConstraintsBySchema added in v0.4.23

func (_m *MockSqlDatabase) GetTableConstraintsBySchema(ctx context.Context, schemas []string) (*TableConstraints, error)

GetTableConstraintsBySchema provides a mock function with given fields: ctx, schemas

func (*MockSqlDatabase) GetTableInitStatements added in v0.4.24

func (_m *MockSqlDatabase) GetTableInitStatements(ctx context.Context, tables []*SchemaTable) ([]*TableInitStatement, error)

GetTableInitStatements provides a mock function with given fields: ctx, tables

func (*MockSqlDatabase) GetTableRowCount added in v0.4.24

func (_m *MockSqlDatabase) GetTableRowCount(ctx context.Context, schema string, table string, whereClause *string) (int64, error)

GetTableRowCount provides a mock function with given fields: ctx, schema, table, whereClause

func (*MockSqlDatabase) GetUniqueConstraintsMap

func (_m *MockSqlDatabase) GetUniqueConstraintsMap(ctx context.Context, schemas []string) (map[string][][]string, error)

GetUniqueConstraintsMap provides a mock function with given fields: ctx, schemas

type MockSqlDatabase_BatchExec_Call

type MockSqlDatabase_BatchExec_Call struct {
	*mock.Call
}

MockSqlDatabase_BatchExec_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BatchExec'

func (*MockSqlDatabase_BatchExec_Call) Return

func (*MockSqlDatabase_BatchExec_Call) Run

func (_c *MockSqlDatabase_BatchExec_Call) Run(run func(ctx context.Context, batchSize int, statements []string, opts *BatchExecOpts)) *MockSqlDatabase_BatchExec_Call

func (*MockSqlDatabase_BatchExec_Call) RunAndReturn

type MockSqlDatabase_Close_Call

type MockSqlDatabase_Close_Call struct {
	*mock.Call
}

MockSqlDatabase_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'

func (*MockSqlDatabase_Close_Call) Return

func (*MockSqlDatabase_Close_Call) Run

func (*MockSqlDatabase_Close_Call) RunAndReturn

func (_c *MockSqlDatabase_Close_Call) RunAndReturn(run func()) *MockSqlDatabase_Close_Call

type MockSqlDatabase_Exec_Call

type MockSqlDatabase_Exec_Call struct {
	*mock.Call
}

MockSqlDatabase_Exec_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exec'

func (*MockSqlDatabase_Exec_Call) Return

func (*MockSqlDatabase_Exec_Call) Run

func (_c *MockSqlDatabase_Exec_Call) Run(run func(ctx context.Context, statement string)) *MockSqlDatabase_Exec_Call

func (*MockSqlDatabase_Exec_Call) RunAndReturn

type MockSqlDatabase_Expecter

type MockSqlDatabase_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockSqlDatabase_Expecter) BatchExec

func (_e *MockSqlDatabase_Expecter) BatchExec(ctx interface{}, batchSize interface{}, statements interface{}, opts interface{}) *MockSqlDatabase_BatchExec_Call

BatchExec is a helper method to define mock.On call

  • ctx context.Context
  • batchSize int
  • statements []string
  • opts *BatchExecOpts

func (*MockSqlDatabase_Expecter) Close

Close is a helper method to define mock.On call

func (*MockSqlDatabase_Expecter) Exec

func (_e *MockSqlDatabase_Expecter) Exec(ctx interface{}, statement interface{}) *MockSqlDatabase_Exec_Call

Exec is a helper method to define mock.On call

  • ctx context.Context
  • statement string

func (*MockSqlDatabase_Expecter) GetCreateTableStatement

func (_e *MockSqlDatabase_Expecter) GetCreateTableStatement(ctx interface{}, schema interface{}, table interface{}) *MockSqlDatabase_GetCreateTableStatement_Call

GetCreateTableStatement is a helper method to define mock.On call

  • ctx context.Context
  • schema string
  • table string

func (*MockSqlDatabase_Expecter) GetDatabaseSchema

func (_e *MockSqlDatabase_Expecter) GetDatabaseSchema(ctx interface{}) *MockSqlDatabase_GetDatabaseSchema_Call

GetDatabaseSchema is a helper method to define mock.On call

  • ctx context.Context

func (*MockSqlDatabase_Expecter) GetForeignKeyConstraints

func (_e *MockSqlDatabase_Expecter) GetForeignKeyConstraints(ctx interface{}, schemas interface{}) *MockSqlDatabase_GetForeignKeyConstraints_Call

GetForeignKeyConstraints is a helper method to define mock.On call

  • ctx context.Context
  • schemas []string

func (*MockSqlDatabase_Expecter) GetForeignKeyConstraintsMap

func (_e *MockSqlDatabase_Expecter) GetForeignKeyConstraintsMap(ctx interface{}, schemas interface{}) *MockSqlDatabase_GetForeignKeyConstraintsMap_Call

GetForeignKeyConstraintsMap is a helper method to define mock.On call

  • ctx context.Context
  • schemas []string

func (*MockSqlDatabase_Expecter) GetPrimaryKeyConstraints

func (_e *MockSqlDatabase_Expecter) GetPrimaryKeyConstraints(ctx interface{}, schemas interface{}) *MockSqlDatabase_GetPrimaryKeyConstraints_Call

GetPrimaryKeyConstraints is a helper method to define mock.On call

  • ctx context.Context
  • schemas []string

func (*MockSqlDatabase_Expecter) GetPrimaryKeyConstraintsMap

func (_e *MockSqlDatabase_Expecter) GetPrimaryKeyConstraintsMap(ctx interface{}, schemas interface{}) *MockSqlDatabase_GetPrimaryKeyConstraintsMap_Call

GetPrimaryKeyConstraintsMap is a helper method to define mock.On call

  • ctx context.Context
  • schemas []string

func (*MockSqlDatabase_Expecter) GetRolePermissionsMap

func (_e *MockSqlDatabase_Expecter) GetRolePermissionsMap(ctx interface{}, role interface{}) *MockSqlDatabase_GetRolePermissionsMap_Call

GetRolePermissionsMap is a helper method to define mock.On call

  • ctx context.Context
  • role string

func (*MockSqlDatabase_Expecter) GetSchemaColumnMap

func (_e *MockSqlDatabase_Expecter) GetSchemaColumnMap(ctx interface{}) *MockSqlDatabase_GetSchemaColumnMap_Call

GetSchemaColumnMap is a helper method to define mock.On call

  • ctx context.Context

func (*MockSqlDatabase_Expecter) GetTableConstraintsBySchema added in v0.4.23

func (_e *MockSqlDatabase_Expecter) GetTableConstraintsBySchema(ctx interface{}, schemas interface{}) *MockSqlDatabase_GetTableConstraintsBySchema_Call

GetTableConstraintsBySchema is a helper method to define mock.On call

  • ctx context.Context
  • schemas []string

func (*MockSqlDatabase_Expecter) GetTableInitStatements added in v0.4.24

func (_e *MockSqlDatabase_Expecter) GetTableInitStatements(ctx interface{}, tables interface{}) *MockSqlDatabase_GetTableInitStatements_Call

GetTableInitStatements is a helper method to define mock.On call

  • ctx context.Context
  • tables []*SchemaTable

func (*MockSqlDatabase_Expecter) GetTableRowCount added in v0.4.24

func (_e *MockSqlDatabase_Expecter) GetTableRowCount(ctx interface{}, schema interface{}, table interface{}, whereClause interface{}) *MockSqlDatabase_GetTableRowCount_Call

GetTableRowCount is a helper method to define mock.On call

  • ctx context.Context
  • schema string
  • table string
  • whereClause *string

func (*MockSqlDatabase_Expecter) GetUniqueConstraintsMap

func (_e *MockSqlDatabase_Expecter) GetUniqueConstraintsMap(ctx interface{}, schemas interface{}) *MockSqlDatabase_GetUniqueConstraintsMap_Call

GetUniqueConstraintsMap is a helper method to define mock.On call

  • ctx context.Context
  • schemas []string

type MockSqlDatabase_GetCreateTableStatement_Call

type MockSqlDatabase_GetCreateTableStatement_Call struct {
	*mock.Call
}

MockSqlDatabase_GetCreateTableStatement_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCreateTableStatement'

func (*MockSqlDatabase_GetCreateTableStatement_Call) Return

func (*MockSqlDatabase_GetCreateTableStatement_Call) Run

func (*MockSqlDatabase_GetCreateTableStatement_Call) RunAndReturn

type MockSqlDatabase_GetDatabaseSchema_Call

type MockSqlDatabase_GetDatabaseSchema_Call struct {
	*mock.Call
}

MockSqlDatabase_GetDatabaseSchema_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDatabaseSchema'

func (*MockSqlDatabase_GetDatabaseSchema_Call) Return

func (*MockSqlDatabase_GetDatabaseSchema_Call) Run

func (*MockSqlDatabase_GetDatabaseSchema_Call) RunAndReturn

type MockSqlDatabase_GetForeignKeyConstraintsMap_Call

type MockSqlDatabase_GetForeignKeyConstraintsMap_Call struct {
	*mock.Call
}

MockSqlDatabase_GetForeignKeyConstraintsMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetForeignKeyConstraintsMap'

func (*MockSqlDatabase_GetForeignKeyConstraintsMap_Call) Return

func (*MockSqlDatabase_GetForeignKeyConstraintsMap_Call) Run

func (*MockSqlDatabase_GetForeignKeyConstraintsMap_Call) RunAndReturn

type MockSqlDatabase_GetForeignKeyConstraints_Call

type MockSqlDatabase_GetForeignKeyConstraints_Call struct {
	*mock.Call
}

MockSqlDatabase_GetForeignKeyConstraints_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetForeignKeyConstraints'

func (*MockSqlDatabase_GetForeignKeyConstraints_Call) Return

func (*MockSqlDatabase_GetForeignKeyConstraints_Call) Run

func (*MockSqlDatabase_GetForeignKeyConstraints_Call) RunAndReturn

type MockSqlDatabase_GetPrimaryKeyConstraintsMap_Call

type MockSqlDatabase_GetPrimaryKeyConstraintsMap_Call struct {
	*mock.Call
}

MockSqlDatabase_GetPrimaryKeyConstraintsMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPrimaryKeyConstraintsMap'

func (*MockSqlDatabase_GetPrimaryKeyConstraintsMap_Call) Return

func (*MockSqlDatabase_GetPrimaryKeyConstraintsMap_Call) Run

func (*MockSqlDatabase_GetPrimaryKeyConstraintsMap_Call) RunAndReturn

type MockSqlDatabase_GetPrimaryKeyConstraints_Call

type MockSqlDatabase_GetPrimaryKeyConstraints_Call struct {
	*mock.Call
}

MockSqlDatabase_GetPrimaryKeyConstraints_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPrimaryKeyConstraints'

func (*MockSqlDatabase_GetPrimaryKeyConstraints_Call) Return

func (*MockSqlDatabase_GetPrimaryKeyConstraints_Call) Run

func (*MockSqlDatabase_GetPrimaryKeyConstraints_Call) RunAndReturn

type MockSqlDatabase_GetRolePermissionsMap_Call

type MockSqlDatabase_GetRolePermissionsMap_Call struct {
	*mock.Call
}

MockSqlDatabase_GetRolePermissionsMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRolePermissionsMap'

func (*MockSqlDatabase_GetRolePermissionsMap_Call) Return

func (*MockSqlDatabase_GetRolePermissionsMap_Call) Run

func (*MockSqlDatabase_GetRolePermissionsMap_Call) RunAndReturn

type MockSqlDatabase_GetSchemaColumnMap_Call

type MockSqlDatabase_GetSchemaColumnMap_Call struct {
	*mock.Call
}

MockSqlDatabase_GetSchemaColumnMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSchemaColumnMap'

func (*MockSqlDatabase_GetSchemaColumnMap_Call) Return

func (*MockSqlDatabase_GetSchemaColumnMap_Call) Run

func (*MockSqlDatabase_GetSchemaColumnMap_Call) RunAndReturn

type MockSqlDatabase_GetTableConstraintsBySchema_Call added in v0.4.23

type MockSqlDatabase_GetTableConstraintsBySchema_Call struct {
	*mock.Call
}

MockSqlDatabase_GetTableConstraintsBySchema_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTableConstraintsBySchema'

func (*MockSqlDatabase_GetTableConstraintsBySchema_Call) Return added in v0.4.23

func (*MockSqlDatabase_GetTableConstraintsBySchema_Call) Run added in v0.4.23

func (*MockSqlDatabase_GetTableConstraintsBySchema_Call) RunAndReturn added in v0.4.23

type MockSqlDatabase_GetTableInitStatements_Call added in v0.4.24

type MockSqlDatabase_GetTableInitStatements_Call struct {
	*mock.Call
}

MockSqlDatabase_GetTableInitStatements_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTableInitStatements'

func (*MockSqlDatabase_GetTableInitStatements_Call) Return added in v0.4.24

func (*MockSqlDatabase_GetTableInitStatements_Call) Run added in v0.4.24

func (*MockSqlDatabase_GetTableInitStatements_Call) RunAndReturn added in v0.4.24

type MockSqlDatabase_GetTableRowCount_Call added in v0.4.24

type MockSqlDatabase_GetTableRowCount_Call struct {
	*mock.Call
}

MockSqlDatabase_GetTableRowCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTableRowCount'

func (*MockSqlDatabase_GetTableRowCount_Call) Return added in v0.4.24

func (*MockSqlDatabase_GetTableRowCount_Call) Run added in v0.4.24

func (*MockSqlDatabase_GetTableRowCount_Call) RunAndReturn added in v0.4.24

type MockSqlDatabase_GetUniqueConstraintsMap_Call

type MockSqlDatabase_GetUniqueConstraintsMap_Call struct {
	*mock.Call
}

MockSqlDatabase_GetUniqueConstraintsMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUniqueConstraintsMap'

func (*MockSqlDatabase_GetUniqueConstraintsMap_Call) Return

func (*MockSqlDatabase_GetUniqueConstraintsMap_Call) Run

func (*MockSqlDatabase_GetUniqueConstraintsMap_Call) RunAndReturn

type MockSqlManagerClient

type MockSqlManagerClient struct {
	mock.Mock
}

MockSqlManagerClient is an autogenerated mock type for the SqlManagerClient type

func NewMockSqlManagerClient

func NewMockSqlManagerClient(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockSqlManagerClient

NewMockSqlManagerClient creates a new instance of MockSqlManagerClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockSqlManagerClient) EXPECT

func (*MockSqlManagerClient) NewPooledSqlDb

func (_m *MockSqlManagerClient) NewPooledSqlDb(ctx context.Context, slogger *slog.Logger, connection *mgmtv1alpha1.Connection) (*SqlConnection, error)

NewPooledSqlDb provides a mock function with given fields: ctx, slogger, connection

func (*MockSqlManagerClient) NewSqlDb

func (_m *MockSqlManagerClient) NewSqlDb(ctx context.Context, slogger *slog.Logger, connection *mgmtv1alpha1.Connection, connectionTimeout *int) (*SqlConnection, error)

NewSqlDb provides a mock function with given fields: ctx, slogger, connection, connectionTimeout

func (*MockSqlManagerClient) NewSqlDbFromConnectionConfig

func (_m *MockSqlManagerClient) NewSqlDbFromConnectionConfig(ctx context.Context, slogger *slog.Logger, connectionConfig *mgmtv1alpha1.ConnectionConfig, connectionTimeout *int) (*SqlConnection, error)

NewSqlDbFromConnectionConfig provides a mock function with given fields: ctx, slogger, connectionConfig, connectionTimeout

func (*MockSqlManagerClient) NewSqlDbFromUrl

func (_m *MockSqlManagerClient) NewSqlDbFromUrl(ctx context.Context, driver string, connectionUrl string) (*SqlConnection, error)

NewSqlDbFromUrl provides a mock function with given fields: ctx, driver, connectionUrl

type MockSqlManagerClient_Expecter

type MockSqlManagerClient_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockSqlManagerClient_Expecter) NewPooledSqlDb

func (_e *MockSqlManagerClient_Expecter) NewPooledSqlDb(ctx interface{}, slogger interface{}, connection interface{}) *MockSqlManagerClient_NewPooledSqlDb_Call

NewPooledSqlDb is a helper method to define mock.On call

  • ctx context.Context
  • slogger *slog.Logger
  • connection *mgmtv1alpha1.Connection

func (*MockSqlManagerClient_Expecter) NewSqlDb

func (_e *MockSqlManagerClient_Expecter) NewSqlDb(ctx interface{}, slogger interface{}, connection interface{}, connectionTimeout interface{}) *MockSqlManagerClient_NewSqlDb_Call

NewSqlDb is a helper method to define mock.On call

  • ctx context.Context
  • slogger *slog.Logger
  • connection *mgmtv1alpha1.Connection
  • connectionTimeout *int

func (*MockSqlManagerClient_Expecter) NewSqlDbFromConnectionConfig

func (_e *MockSqlManagerClient_Expecter) NewSqlDbFromConnectionConfig(ctx interface{}, slogger interface{}, connectionConfig interface{}, connectionTimeout interface{}) *MockSqlManagerClient_NewSqlDbFromConnectionConfig_Call

NewSqlDbFromConnectionConfig is a helper method to define mock.On call

  • ctx context.Context
  • slogger *slog.Logger
  • connectionConfig *mgmtv1alpha1.ConnectionConfig
  • connectionTimeout *int

func (*MockSqlManagerClient_Expecter) NewSqlDbFromUrl

func (_e *MockSqlManagerClient_Expecter) NewSqlDbFromUrl(ctx interface{}, driver interface{}, connectionUrl interface{}) *MockSqlManagerClient_NewSqlDbFromUrl_Call

NewSqlDbFromUrl is a helper method to define mock.On call

  • ctx context.Context
  • driver string
  • connectionUrl string

type MockSqlManagerClient_NewPooledSqlDb_Call

type MockSqlManagerClient_NewPooledSqlDb_Call struct {
	*mock.Call
}

MockSqlManagerClient_NewPooledSqlDb_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewPooledSqlDb'

func (*MockSqlManagerClient_NewPooledSqlDb_Call) Return

func (*MockSqlManagerClient_NewPooledSqlDb_Call) Run

func (*MockSqlManagerClient_NewPooledSqlDb_Call) RunAndReturn

type MockSqlManagerClient_NewSqlDbFromConnectionConfig_Call

type MockSqlManagerClient_NewSqlDbFromConnectionConfig_Call struct {
	*mock.Call
}

MockSqlManagerClient_NewSqlDbFromConnectionConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewSqlDbFromConnectionConfig'

func (*MockSqlManagerClient_NewSqlDbFromConnectionConfig_Call) Return

func (*MockSqlManagerClient_NewSqlDbFromConnectionConfig_Call) Run

type MockSqlManagerClient_NewSqlDbFromUrl_Call

type MockSqlManagerClient_NewSqlDbFromUrl_Call struct {
	*mock.Call
}

MockSqlManagerClient_NewSqlDbFromUrl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewSqlDbFromUrl'

func (*MockSqlManagerClient_NewSqlDbFromUrl_Call) Return

func (*MockSqlManagerClient_NewSqlDbFromUrl_Call) Run

func (*MockSqlManagerClient_NewSqlDbFromUrl_Call) RunAndReturn

type MockSqlManagerClient_NewSqlDb_Call

type MockSqlManagerClient_NewSqlDb_Call struct {
	*mock.Call
}

MockSqlManagerClient_NewSqlDb_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewSqlDb'

func (*MockSqlManagerClient_NewSqlDb_Call) Return

func (*MockSqlManagerClient_NewSqlDb_Call) Run

func (_c *MockSqlManagerClient_NewSqlDb_Call) Run(run func(ctx context.Context, slogger *slog.Logger, connection *mgmtv1alpha1.Connection, connectionTimeout *int)) *MockSqlManagerClient_NewSqlDb_Call

func (*MockSqlManagerClient_NewSqlDb_Call) RunAndReturn

type MysqlManager

type MysqlManager struct {
	// contains filtered or unexported fields
}

func (*MysqlManager) BatchExec

func (m *MysqlManager) BatchExec(ctx context.Context, batchSize int, statements []string, opts *BatchExecOpts) error

func (*MysqlManager) Close

func (m *MysqlManager) Close()

func (*MysqlManager) Exec

func (m *MysqlManager) Exec(ctx context.Context, statement string) error

func (*MysqlManager) GetCreateTableStatement

func (m *MysqlManager) GetCreateTableStatement(ctx context.Context, schema, table string) (string, error)

func (*MysqlManager) GetDatabaseSchema

func (m *MysqlManager) GetDatabaseSchema(ctx context.Context) ([]*DatabaseSchemaRow, error)

func (*MysqlManager) GetForeignKeyConstraints

func (m *MysqlManager) GetForeignKeyConstraints(ctx context.Context, schemas []string) ([]*ForeignKeyConstraintsRow, error)

func (*MysqlManager) GetForeignKeyConstraintsMap

func (m *MysqlManager) GetForeignKeyConstraintsMap(ctx context.Context, schemas []string) (map[string][]*ForeignConstraint, error)

Key is schema.table value is list of tables that key depends on

func (*MysqlManager) GetPrimaryKeyConstraints

func (m *MysqlManager) GetPrimaryKeyConstraints(ctx context.Context, schemas []string) ([]*PrimaryKey, error)

func (*MysqlManager) GetPrimaryKeyConstraintsMap

func (m *MysqlManager) GetPrimaryKeyConstraintsMap(ctx context.Context, schemas []string) (map[string][]string, error)

func (*MysqlManager) GetRolePermissionsMap

func (m *MysqlManager) GetRolePermissionsMap(ctx context.Context, role string) (map[string][]string, error)

func (*MysqlManager) GetSchemaColumnMap

func (m *MysqlManager) GetSchemaColumnMap(ctx context.Context) (map[string]map[string]*ColumnInfo, error)

returns: {public.users: { id: struct{}{}, created_at: struct{}{}}}

func (*MysqlManager) GetTableConstraintsBySchema added in v0.4.23

func (m *MysqlManager) GetTableConstraintsBySchema(ctx context.Context, schemas []string) (*TableConstraints, error)

func (*MysqlManager) GetTableInitStatements added in v0.4.24

func (m *MysqlManager) GetTableInitStatements(ctx context.Context, tables []*SchemaTable) ([]*TableInitStatement, error)

todo

func (*MysqlManager) GetTableRowCount added in v0.4.24

func (m *MysqlManager) GetTableRowCount(
	ctx context.Context,
	schema, table string,
	whereClause *string,
) (int64, error)

func (*MysqlManager) GetUniqueConstraintsMap

func (m *MysqlManager) GetUniqueConstraintsMap(ctx context.Context, schemas []string) (map[string][][]string, error)

type PostgresManager

type PostgresManager struct {
	// contains filtered or unexported fields
}

func (*PostgresManager) BatchExec

func (p *PostgresManager) BatchExec(ctx context.Context, batchSize int, statements []string, opts *BatchExecOpts) error

func (*PostgresManager) Close

func (p *PostgresManager) Close()

func (*PostgresManager) Exec

func (p *PostgresManager) Exec(ctx context.Context, statement string) error

func (*PostgresManager) GetCreateTableStatement

func (p *PostgresManager) GetCreateTableStatement(ctx context.Context, schema, table string) (string, error)

func (*PostgresManager) GetDatabaseSchema

func (p *PostgresManager) GetDatabaseSchema(ctx context.Context) ([]*DatabaseSchemaRow, error)

func (*PostgresManager) GetForeignKeyConstraints

func (p *PostgresManager) GetForeignKeyConstraints(ctx context.Context, schemas []string) ([]*ForeignKeyConstraintsRow, error)

func (*PostgresManager) GetForeignKeyConstraintsMap

func (p *PostgresManager) GetForeignKeyConstraintsMap(ctx context.Context, schemas []string) (map[string][]*ForeignConstraint, error)

Key is schema.table value is list of tables that key depends on

func (*PostgresManager) GetPrimaryKeyConstraints

func (p *PostgresManager) GetPrimaryKeyConstraints(ctx context.Context, schemas []string) ([]*PrimaryKey, error)

func (*PostgresManager) GetPrimaryKeyConstraintsMap

func (p *PostgresManager) GetPrimaryKeyConstraintsMap(ctx context.Context, schemas []string) (map[string][]string, error)

func (*PostgresManager) GetRolePermissionsMap

func (p *PostgresManager) GetRolePermissionsMap(ctx context.Context, role string) (map[string][]string, error)

func (*PostgresManager) GetSchemaColumnMap

func (p *PostgresManager) GetSchemaColumnMap(ctx context.Context) (map[string]map[string]*ColumnInfo, error)

returns: {public.users: { id: struct{}{}, created_at: struct{}{}}}

func (*PostgresManager) GetTableConstraintsBySchema added in v0.4.23

func (p *PostgresManager) GetTableConstraintsBySchema(ctx context.Context, schemas []string) (*TableConstraints, error)

func (*PostgresManager) GetTableInitStatements added in v0.4.24

func (p *PostgresManager) GetTableInitStatements(ctx context.Context, tables []*SchemaTable) ([]*TableInitStatement, error)

func (*PostgresManager) GetTableRowCount added in v0.4.24

func (p *PostgresManager) GetTableRowCount(
	ctx context.Context,
	schema, table string,
	whereClause *string,
) (int64, error)

func (*PostgresManager) GetUniqueConstraintsMap

func (p *PostgresManager) GetUniqueConstraintsMap(ctx context.Context, schemas []string) (map[string][][]string, error)

type PrimaryKey

type PrimaryKey struct {
	Schema  string
	Table   string
	Columns []string
}

type SchemaTable added in v0.4.24

type SchemaTable struct {
	Schema string
	Table  string
}

func (SchemaTable) String added in v0.4.24

func (s SchemaTable) String() string

type SqlConnection

type SqlConnection struct {
	Db     SqlDatabase
	Driver string
}

type SqlDatabase

type SqlDatabase interface {
	GetDatabaseSchema(ctx context.Context) ([]*DatabaseSchemaRow, error)
	GetSchemaColumnMap(ctx context.Context) (map[string]map[string]*ColumnInfo, error) // ex: {public.users: { id: struct{}{}, created_at: struct{}{}}}
	GetTableConstraintsBySchema(ctx context.Context, schemas []string) (*TableConstraints, error)
	GetForeignKeyConstraints(ctx context.Context, schemas []string) ([]*ForeignKeyConstraintsRow, error)
	GetForeignKeyConstraintsMap(ctx context.Context, schemas []string) (map[string][]*ForeignConstraint, error)
	GetPrimaryKeyConstraints(ctx context.Context, schemas []string) ([]*PrimaryKey, error)
	GetPrimaryKeyConstraintsMap(ctx context.Context, schemas []string) (map[string][]string, error)
	GetUniqueConstraintsMap(ctx context.Context, schemas []string) (map[string][][]string, error)
	GetCreateTableStatement(ctx context.Context, schema, table string) (string, error)
	GetTableInitStatements(ctx context.Context, tables []*SchemaTable) ([]*TableInitStatement, error)
	GetRolePermissionsMap(ctx context.Context, role string) (map[string][]string, error)
	GetTableRowCount(ctx context.Context, schema, table string, whereClause *string) (int64, error)
	BatchExec(ctx context.Context, batchSize int, statements []string, opts *BatchExecOpts) error
	Exec(ctx context.Context, statement string) error
	Close()
}

type SqlManager

type SqlManager struct {
	// contains filtered or unexported fields
}

func NewSqlManager

func NewSqlManager(
	pgpool *sync.Map,
	pgquerier pg_queries.Querier,
	mysqlpool *sync.Map,
	mysqlquerier mysql_queries.Querier,
	sqlconnector sqlconnect.SqlConnector,
) *SqlManager

func (*SqlManager) NewPooledSqlDb

func (s *SqlManager) NewPooledSqlDb(
	ctx context.Context,
	slogger *slog.Logger,
	connection *mgmtv1alpha1.Connection,
) (*SqlConnection, error)

func (*SqlManager) NewSqlDb

func (s *SqlManager) NewSqlDb(
	ctx context.Context,
	slogger *slog.Logger,
	connection *mgmtv1alpha1.Connection,
	connectionTimeout *int,
) (*SqlConnection, error)

func (*SqlManager) NewSqlDbFromConnectionConfig

func (s *SqlManager) NewSqlDbFromConnectionConfig(
	ctx context.Context,
	slogger *slog.Logger,
	connectionConfig *mgmtv1alpha1.ConnectionConfig,
	connectionTimeout *int,
) (*SqlConnection, error)

func (*SqlManager) NewSqlDbFromUrl

func (s *SqlManager) NewSqlDbFromUrl(
	ctx context.Context,
	driver, connectionUrl string,
) (*SqlConnection, error)

type SqlManagerClient

type SqlManagerClient interface {
	NewPooledSqlDb(
		ctx context.Context,
		slogger *slog.Logger,
		connection *mgmtv1alpha1.Connection,
	) (*SqlConnection, error)
	NewSqlDb(
		ctx context.Context,
		slogger *slog.Logger,
		connection *mgmtv1alpha1.Connection,
		connectionTimeout *int,
	) (*SqlConnection, error)
	NewSqlDbFromUrl(
		ctx context.Context,
		driver, connectionUrl string,
	) (*SqlConnection, error)
	NewSqlDbFromConnectionConfig(
		ctx context.Context,
		slogger *slog.Logger,
		connectionConfig *mgmtv1alpha1.ConnectionConfig,
		connectionTimeout *int,
	) (*SqlConnection, error)
}

type TableConstraints added in v0.4.23

type TableConstraints struct {
	ForeignKeyConstraints map[string][]*ForeignConstraint
	PrimaryKeyConstraints map[string][]string
	UniqueConstraints     map[string][][]string
}

type TableInitStatement added in v0.4.24

type TableInitStatement struct {
	CreateTableStatement string
	AlterTableStatements []*AlterTableStatement
	IndexStatements      []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL