Documentation
¶
Index ¶
- func Cleanf(format string, args ...interface{}) string
- type DBAdapter
- type DBNotifyTriggerAdapter
- type PostgresAdapter
- func (pa *PostgresAdapter) AlterColumnQuery(tableName, columnName string, sqlColumnType types.SQLColumnType, ...) (string, string)
- func (pa *PostgresAdapter) CleanDBQueries() types.SQLCleanDBQuery
- func (pa *PostgresAdapter) CreateNotifyFunctionQuery(function, channel string, columns ...string) string
- func (pa *PostgresAdapter) CreateTableQuery(tableName string, columns []*types.SQLTableColumn) (string, string)
- func (pa *PostgresAdapter) CreateTriggerQuery(triggerName, tableName, functionName string) string
- func (pa *PostgresAdapter) DeleteQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, error)
- func (pa *PostgresAdapter) DropTableQuery(tableName string) string
- func (pa *PostgresAdapter) ErrorEquals(err error, sqlErrorType types.SQLErrorType) bool
- func (pa *PostgresAdapter) FindTableQuery() string
- func (pa *PostgresAdapter) InsertLogQuery() string
- func (pa *PostgresAdapter) Open(dbURL string) (*sqlx.DB, error)
- func (pa *PostgresAdapter) RestoreDBQuery() string
- func (pa *PostgresAdapter) SchemaName(tableName string) string
- func (pa *PostgresAdapter) SecureName(name string) string
- func (pa *PostgresAdapter) SelectLogQuery() string
- func (pa *PostgresAdapter) SelectRowQuery(tableName, fields, indexValue string) string
- func (pa *PostgresAdapter) TableDefinitionQuery() string
- func (pa *PostgresAdapter) TypeMapping(sqlColumnType types.SQLColumnType) (string, error)
- func (pa *PostgresAdapter) UpsertQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, interface{}, error)
- type SQLiteAdapter
- func (*SQLiteAdapter) AlterColumnQuery(tableName, columnName string, sqlColumnType types.SQLColumnType, ...) (string, string)
- func (*SQLiteAdapter) CleanDBQueries() types.SQLCleanDBQuery
- func (*SQLiteAdapter) CreateTableQuery(tableName string, columns []*types.SQLTableColumn) (string, string)
- func (*SQLiteAdapter) DeleteQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, error)
- func (*SQLiteAdapter) DropTableQuery(tableName string) string
- func (*SQLiteAdapter) ErrorEquals(err error, sqlErrorType types.SQLErrorType) bool
- func (*SQLiteAdapter) FindTableQuery() string
- func (*SQLiteAdapter) InsertLogQuery() string
- func (*SQLiteAdapter) Open(dbURL string) (*sqlx.DB, error)
- func (*SQLiteAdapter) RestoreDBQuery() string
- func (*SQLiteAdapter) SchemaName(tableName string) string
- func (*SQLiteAdapter) SecureName(name string) string
- func (*SQLiteAdapter) SelectLogQuery() string
- func (*SQLiteAdapter) SelectRowQuery(tableName, fields, indexValue string) string
- func (*SQLiteAdapter) TableDefinitionQuery() string
- func (*SQLiteAdapter) TypeMapping(sqlColumnType types.SQLColumnType) (string, error)
- func (*SQLiteAdapter) UpsertQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DBAdapter ¶
type DBAdapter interface {
Open(dbURL string) (*sqlx.DB, error)
// TODO: incrementally refactor DBAdapter to be responsible for actually _doing_ the queries,
// TODO: legacy stringly queries:
// TypeMapping maps generic SQL column types to db adapter dependent column types
TypeMapping(sqlColumnType types.SQLColumnType) (string, error)
// ErrorEquals compares generic SQL errors to db adapter dependent errors
ErrorEquals(err error, sqlErrorType types.SQLErrorType) bool
// SecureColumnName returns columns with proper delimiters to ensure well formed column names
SecureName(name string) string
// CreateTableQuery builds a CREATE TABLE query to create a new table
CreateTableQuery(tableName string, columns []*types.SQLTableColumn) (string, string)
// FindTableQuery builds a SELECT query to check if a table exists
FindTableQuery() string
// TableDefinitionQuery builds a SELECT query to get a table structure from the Dictionary table
TableDefinitionQuery() string
// AlterColumnQuery builds an ALTER COLUMN query to alter a table structure (only adding columns is supported)
AlterColumnQuery(tableName, columnName string, sqlColumnType types.SQLColumnType, length, order int) (string, string)
// SelectRowQuery builds a SELECT query to get row values
SelectRowQuery(tableName, fields, indexValue string) string
// SelectLogQuery builds a SELECT query to get all tables involved in a given block transaction
SelectLogQuery() string
// InsertLogQuery builds an INSERT query to store data in Log table
InsertLogQuery() string
// UpsertQuery builds an INSERT... ON CONFLICT (or similar) query to upsert data in event tables based on PK
UpsertQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, interface{}, error)
// DeleteQuery builds a DELETE FROM event tables query based on PK
DeleteQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, error)
// RestoreDBQuery builds a list of sql clauses needed to restore the db to a point in time
RestoreDBQuery() string
// CleanDBQueries returns necessary queries to clean the database
CleanDBQueries() types.SQLCleanDBQuery
// DropTableQuery builds a DROP TABLE query to delete a table
DropTableQuery(tableName string) string
// Get the schema qualified name of the given table
SchemaName(tableName string) string
}
DBAdapter implements database dependent interface
type DBNotifyTriggerAdapter ¶
type DBNotifyTriggerAdapter interface {
// Create a SQL function that notifies on channel with the payload of columns - the payload containing the value
// of each column will be sent once whenever any of the columns changes. Expected to replace existing function.
CreateNotifyFunctionQuery(function, channel string, columns ...string) string
// Create a trigger that fires the named function after any operation on a row in table. Expected to replace existing
// trigger.
CreateTriggerQuery(triggerName, tableName, functionName string) string
}
type PostgresAdapter ¶
PostgresAdapter implements DBAdapter for Postgres
func NewPostgresAdapter ¶
func NewPostgresAdapter(schema string, sqlNames types.SQLNames, log *logging.Logger) *PostgresAdapter
NewPostgresAdapter constructs a new db adapter
func (*PostgresAdapter) AlterColumnQuery ¶
func (pa *PostgresAdapter) AlterColumnQuery(tableName, columnName string, sqlColumnType types.SQLColumnType, length, order int) (string, string)
AlterColumnQuery returns a query for adding a new column to a table
func (*PostgresAdapter) CleanDBQueries ¶
func (pa *PostgresAdapter) CleanDBQueries() types.SQLCleanDBQuery
func (*PostgresAdapter) CreateNotifyFunctionQuery ¶
func (pa *PostgresAdapter) CreateNotifyFunctionQuery(function, channel string, columns ...string) string
func (*PostgresAdapter) CreateTableQuery ¶
func (pa *PostgresAdapter) CreateTableQuery(tableName string, columns []*types.SQLTableColumn) (string, string)
CreateTableQuery builds query for creating a new table
func (*PostgresAdapter) CreateTriggerQuery ¶
func (pa *PostgresAdapter) CreateTriggerQuery(triggerName, tableName, functionName string) string
func (*PostgresAdapter) DeleteQuery ¶
func (pa *PostgresAdapter) DeleteQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, error)
func (*PostgresAdapter) DropTableQuery ¶
func (pa *PostgresAdapter) DropTableQuery(tableName string) string
func (*PostgresAdapter) ErrorEquals ¶
func (pa *PostgresAdapter) ErrorEquals(err error, sqlErrorType types.SQLErrorType) bool
ErrorEquals verify if an error is of a given SQL type
func (*PostgresAdapter) FindTableQuery ¶
func (pa *PostgresAdapter) FindTableQuery() string
FindTableQuery returns a query that checks if a table exists
func (*PostgresAdapter) InsertLogQuery ¶
func (pa *PostgresAdapter) InsertLogQuery() string
InsertLogQuery returns a query to insert a row in log table
func (*PostgresAdapter) RestoreDBQuery ¶
func (pa *PostgresAdapter) RestoreDBQuery() string
func (*PostgresAdapter) SchemaName ¶ added in v0.26.0
func (pa *PostgresAdapter) SchemaName(tableName string) string
func (*PostgresAdapter) SecureName ¶
func (pa *PostgresAdapter) SecureName(name string) string
SecureColumnName return columns between appropriate security containers
func (*PostgresAdapter) SelectLogQuery ¶
func (pa *PostgresAdapter) SelectLogQuery() string
SelectLogQuery returns a query for selecting all tables involved in a block trn
func (*PostgresAdapter) SelectRowQuery ¶
func (pa *PostgresAdapter) SelectRowQuery(tableName, fields, indexValue string) string
SelectRowQuery returns a query for selecting row values
func (*PostgresAdapter) TableDefinitionQuery ¶
func (pa *PostgresAdapter) TableDefinitionQuery() string
TableDefinitionQuery returns a query with table structure
func (*PostgresAdapter) TypeMapping ¶
func (pa *PostgresAdapter) TypeMapping(sqlColumnType types.SQLColumnType) (string, error)
TypeMapping convert generic dataTypes to database dependent dataTypes
func (*PostgresAdapter) UpsertQuery ¶
func (pa *PostgresAdapter) UpsertQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, interface{}, error)
type SQLiteAdapter ¶
This is a no-op version of SQLiteAdapter
func NewSQLiteAdapter ¶
func NewSQLiteAdapter(names types.SQLNames, log *logging.Logger) *SQLiteAdapter
func (*SQLiteAdapter) AlterColumnQuery ¶
func (*SQLiteAdapter) AlterColumnQuery(tableName, columnName string, sqlColumnType types.SQLColumnType, length, order int) (string, string)
func (*SQLiteAdapter) CleanDBQueries ¶
func (*SQLiteAdapter) CleanDBQueries() types.SQLCleanDBQuery
func (*SQLiteAdapter) CreateTableQuery ¶
func (*SQLiteAdapter) CreateTableQuery(tableName string, columns []*types.SQLTableColumn) (string, string)
func (*SQLiteAdapter) DeleteQuery ¶
func (*SQLiteAdapter) DeleteQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, error)
func (*SQLiteAdapter) DropTableQuery ¶
func (*SQLiteAdapter) DropTableQuery(tableName string) string
func (*SQLiteAdapter) ErrorEquals ¶
func (*SQLiteAdapter) ErrorEquals(err error, sqlErrorType types.SQLErrorType) bool
func (*SQLiteAdapter) FindTableQuery ¶
func (*SQLiteAdapter) FindTableQuery() string
func (*SQLiteAdapter) InsertLogQuery ¶
func (*SQLiteAdapter) InsertLogQuery() string
func (*SQLiteAdapter) RestoreDBQuery ¶
func (*SQLiteAdapter) RestoreDBQuery() string
func (*SQLiteAdapter) SchemaName ¶ added in v0.26.0
func (*SQLiteAdapter) SchemaName(tableName string) string
func (*SQLiteAdapter) SecureName ¶
func (*SQLiteAdapter) SecureName(name string) string
func (*SQLiteAdapter) SelectLogQuery ¶
func (*SQLiteAdapter) SelectLogQuery() string
func (*SQLiteAdapter) SelectRowQuery ¶
func (*SQLiteAdapter) SelectRowQuery(tableName, fields, indexValue string) string
func (*SQLiteAdapter) TableDefinitionQuery ¶
func (*SQLiteAdapter) TableDefinitionQuery() string
func (*SQLiteAdapter) TypeMapping ¶
func (*SQLiteAdapter) TypeMapping(sqlColumnType types.SQLColumnType) (string, error)
func (*SQLiteAdapter) UpsertQuery ¶
func (*SQLiteAdapter) UpsertQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, interface{}, error)