 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- func Cleanf(format string, args ...interface{}) string
- type DBAdapter
- type DBNotifyTriggerAdapter
- type PostgresAdapter
- func (adapter *PostgresAdapter) AlterColumnQuery(tableName, columnName string, sqlColumnType types.SQLColumnType, ...) (string, string)
- func (adapter *PostgresAdapter) CleanDBQueries() types.SQLCleanDBQuery
- func (adapter *PostgresAdapter) CreateNotifyFunctionQuery(function, channel string, columns ...string) string
- func (adapter *PostgresAdapter) CreateTableQuery(tableName string, columns []*types.SQLTableColumn) (string, string)
- func (adapter *PostgresAdapter) CreateTriggerQuery(triggerName, tableName, functionName string) string
- func (adapter *PostgresAdapter) DeleteQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, error)
- func (adapter *PostgresAdapter) DropTableQuery(tableName string) string
- func (adapter *PostgresAdapter) ErrorEquals(err error, sqlErrorType types.SQLErrorType) bool
- func (adapter *PostgresAdapter) FindTableQuery() string
- func (adapter *PostgresAdapter) InsertLogQuery() string
- func (adapter *PostgresAdapter) LastBlockIDQuery() string
- func (adapter *PostgresAdapter) Open(dbURL string) (*sql.DB, error)
- func (adapter *PostgresAdapter) RestoreDBQuery() string
- func (adapter *PostgresAdapter) SecureName(name string) string
- func (adapter *PostgresAdapter) SelectLogQuery() string
- func (adapter *PostgresAdapter) SelectRowQuery(tableName, fields, indexValue string) string
- func (adapter *PostgresAdapter) TableDefinitionQuery() string
- func (adapter *PostgresAdapter) TypeMapping(sqlColumnType types.SQLColumnType) (string, error)
- func (adapter *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) LastBlockIDQuery() string
- func (*SQLiteAdapter) Open(dbURL string) (*sql.DB, error)
- func (*SQLiteAdapter) RestoreDBQuery() 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 opens a db connection and creates a new schema if the adapter supports that
	Open(dbURL string) (*sql.DB, error)
	// 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)
	// LastBlockIDQuery builds a SELECT query to return the last block# from the Log table
	LastBlockIDQuery() 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
}
    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, log *logger.Logger) *PostgresAdapter
NewPostgresAdapter constructs a new db adapter
func (*PostgresAdapter) AlterColumnQuery ¶
func (adapter *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 (adapter *PostgresAdapter) CleanDBQueries() types.SQLCleanDBQuery
func (*PostgresAdapter) CreateNotifyFunctionQuery ¶
func (adapter *PostgresAdapter) CreateNotifyFunctionQuery(function, channel string, columns ...string) string
func (*PostgresAdapter) CreateTableQuery ¶
func (adapter *PostgresAdapter) CreateTableQuery(tableName string, columns []*types.SQLTableColumn) (string, string)
CreateTableQuery builds query for creating a new table
func (*PostgresAdapter) CreateTriggerQuery ¶
func (adapter *PostgresAdapter) CreateTriggerQuery(triggerName, tableName, functionName string) string
func (*PostgresAdapter) DeleteQuery ¶
func (adapter *PostgresAdapter) DeleteQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, error)
func (*PostgresAdapter) DropTableQuery ¶
func (adapter *PostgresAdapter) DropTableQuery(tableName string) string
func (*PostgresAdapter) ErrorEquals ¶
func (adapter *PostgresAdapter) ErrorEquals(err error, sqlErrorType types.SQLErrorType) bool
ErrorEquals verify if an error is of a given SQL type
func (*PostgresAdapter) FindTableQuery ¶
func (adapter *PostgresAdapter) FindTableQuery() string
FindTableQuery returns a query that checks if a table exists
func (*PostgresAdapter) InsertLogQuery ¶
func (adapter *PostgresAdapter) InsertLogQuery() string
InsertLogQuery returns a query to insert a row in log table
func (*PostgresAdapter) LastBlockIDQuery ¶
func (adapter *PostgresAdapter) LastBlockIDQuery() string
LastBlockIDQuery returns a query for last inserted blockId in log table
func (*PostgresAdapter) Open ¶
func (adapter *PostgresAdapter) Open(dbURL string) (*sql.DB, error)
Open connects to a PostgreSQL database, opens it & create default schema if provided
func (*PostgresAdapter) RestoreDBQuery ¶
func (adapter *PostgresAdapter) RestoreDBQuery() string
func (*PostgresAdapter) SecureName ¶
func (adapter *PostgresAdapter) SecureName(name string) string
SecureColumnName return columns between appropriate security containers
func (*PostgresAdapter) SelectLogQuery ¶
func (adapter *PostgresAdapter) SelectLogQuery() string
SelectLogQuery returns a query for selecting all tables involved in a block trn
func (*PostgresAdapter) SelectRowQuery ¶
func (adapter *PostgresAdapter) SelectRowQuery(tableName, fields, indexValue string) string
SelectRowQuery returns a query for selecting row values
func (*PostgresAdapter) TableDefinitionQuery ¶
func (adapter *PostgresAdapter) TableDefinitionQuery() string
TableDefinitionQuery returns a query with table structure
func (*PostgresAdapter) TypeMapping ¶
func (adapter *PostgresAdapter) TypeMapping(sqlColumnType types.SQLColumnType) (string, error)
TypeMapping convert generic dataTypes to database dependent dataTypes
func (*PostgresAdapter) UpsertQuery ¶
func (adapter *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(log *logger.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) LastBlockIDQuery ¶
func (*SQLiteAdapter) LastBlockIDQuery() string
func (*SQLiteAdapter) RestoreDBQuery ¶
func (*SQLiteAdapter) RestoreDBQuery() 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)