Documentation ¶
Index ¶
- type Database
- func (d Database) AllViews(ctx *sql.Context) ([]sql.ViewDefinition, error)
- func (d Database) CreateTable(ctx *sql.Context, name string, schema sql.PrimaryKeySchema) error
- func (d Database) CreateTrigger(ctx *sql.Context, definition sql.TriggerDefinition) error
- func (d Database) CreateView(ctx *sql.Context, name string, selectStatement string) error
- func (d Database) DropStoredProcedure(ctx *sql.Context, name string) error
- func (d Database) DropTable(ctx *sql.Context, name string) error
- func (d Database) DropTrigger(ctx *sql.Context, name string) error
- func (d Database) DropView(ctx *sql.Context, name string) error
- func (d Database) GetStoredProcedures(ctx *sql.Context) ([]sql.StoredProcedureDetails, error)
- func (d Database) GetTableInsensitive(ctx *sql.Context, tblName string) (sql.Table, bool, error)
- func (d Database) GetTableNames(ctx *sql.Context) ([]string, error)
- func (d Database) GetTriggers(ctx *sql.Context) ([]sql.TriggerDefinition, error)
- func (d Database) GetView(ctx *sql.Context, viewName string) (string, bool, error)
- func (d Database) Name() string
- func (d Database) RenameTable(ctx *sql.Context, oldName, newName string) error
- func (d Database) SaveStoredProcedure(ctx *sql.Context, spd sql.StoredProcedureDetails) error
- type ForeignKeyHarness
- type Harness
- type IndexDriverHarness
- type IndexHarness
- type KeylessTableHarness
- type ReadOnlyDatabaseHarness
- type SQLITEDatabase
- type SQLITEHarness
- func (m *SQLITEHarness) Close()
- func (m *SQLITEHarness) NewContext() *sql.Context
- func (m *SQLITEHarness) NewDatabase(name string) sql.Database
- func (m *SQLITEHarness) NewDatabaseProvider(dbs ...sql.Database) sql.MutableDatabaseProvider
- func (m *SQLITEHarness) NewDatabases(names ...string) []sql.Database
- func (m *SQLITEHarness) NewTable(db sql.Database, name string, schema sql.PrimaryKeySchema) (sql.Table, error)
- func (m *SQLITEHarness) Parallelism() int
- func (m *SQLITEHarness) QueriesToSkip(queries ...string)
- func (m *SQLITEHarness) SkipQueryTest(query string) bool
- func (m *SQLITEHarness) SupportsForeignKeys() bool
- func (m *SQLITEHarness) SupportsKeylessTables() bool
- func (m *SQLITEHarness) SupportsNativeIndexCreation() bool
- type SQLITEShim
- func (m *SQLITEShim) AllDatabases() []sql.Database
- func (m *SQLITEShim) Close()
- func (m *SQLITEShim) CreateDatabase(ctx *sql.Context, name string) error
- func (m *SQLITEShim) Database(name string) (sql.Database, error)
- func (m *SQLITEShim) DropDatabase(ctx *sql.Context, name string) error
- func (m *SQLITEShim) Exec(db string, query string) error
- func (m *SQLITEShim) HasDatabase(name string) bool
- func (m *SQLITEShim) Query(db string, query string) (sql.RowIter, error)
- func (m *SQLITEShim) QueryRows(db string, query string) ([]sql.Row, error)
- type SQLITETable
- type SkippingHarness
- type Table
- func (t Table) AddColumn(ctx *sql.Context, column *sql.Column, order *sql.ColumnOrder) error
- func (t Table) Close(ctx *sql.Context) error
- func (t Table) CreateCheck(ctx *sql.Context, check *sql.CheckDefinition) error
- func (t Table) CreateForeignKey(ctx *sql.Context, fkName string, columns []string, referencedTable string, ...) error
- func (t Table) CreateIndex(ctx *sql.Context, indexName string, using sql.IndexUsing, ...) error
- func (t Table) CreatePrimaryKey(ctx *sql.Context, columns []sql.IndexColumn) error
- func (t Table) DataLength(ctx *sql.Context) (uint64, error)
- func (t Table) Deleter(ctx *sql.Context) sql.RowDeleter
- func (t Table) DropCheck(ctx *sql.Context, chName string) error
- func (t Table) DropColumn(ctx *sql.Context, columnName string) error
- func (t Table) DropForeignKey(ctx *sql.Context, fkName string) error
- func (t Table) DropIndex(ctx *sql.Context, indexName string) error
- func (t Table) DropPrimaryKey(ctx *sql.Context) error
- func (t Table) GetChecks(ctx *sql.Context) ([]sql.CheckDefinition, error)
- func (t Table) GetForeignKeys(ctx *sql.Context) ([]sql.ForeignKeyConstraint, error)
- func (t Table) GetIndexes(ctx *sql.Context) ([]sql.Index, error)
- func (t Table) Inserter(ctx *sql.Context) sql.RowInserter
- func (t Table) ModifyColumn(ctx *sql.Context, columnName string, column *sql.Column, ...) error
- func (t Table) Name() string
- func (t Table) NumRows(ctx *sql.Context) (uint64, error)
- func (t Table) PartitionRows(ctx *sql.Context, partition sql.Partition) (sql.RowIter, error)
- func (t Table) Partitions(ctx *sql.Context) (sql.PartitionIter, error)
- func (t Table) Pks() []sql.IndexColumn
- func (t Table) PrimaryKeySchema() sql.PrimaryKeySchema
- func (t Table) RenameIndex(ctx *sql.Context, fromIndexName string, toIndexName string) error
- func (t Table) Replacer(ctx *sql.Context) sql.RowReplacer
- func (t Table) Schema() sql.Schema
- func (t Table) String() string
- func (t Table) Truncate(ctx *sql.Context) (int, error)
- func (t Table) Updater(ctx *sql.Context) sql.RowUpdater
- func (t Table) WithIndexLookup(lookup sql.IndexLookup) sql.Table
- type TransactionHarness
- type VersionedDBHarness
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database represents a database for a local SQLITE server.
func (Database) CreateTable ¶
CreateTable implements the interface sql.TableCreator.
func (Database) CreateTrigger ¶
CreateTrigger implements the interface sql.TriggerDatabase.
func (Database) CreateView ¶
CreateView implements the interface sql.ViewDatabase.
func (Database) DropStoredProcedure ¶
DropStoredProcedure implements the interface sql.StoredProcedureDatabase.
func (Database) DropTrigger ¶
DropTrigger implements the interface sql.TriggerDatabase.
func (Database) GetStoredProcedures ¶
GetStoredProcedures implements the interface sql.StoredProcedureDatabase.
func (Database) GetTableInsensitive ¶
GetTableInsensitive implements the interface sql.Database.
func (Database) GetTableNames ¶
GetTableNames implements the interface sql.Database.
func (Database) GetTriggers ¶
GetTriggers implements the interface sql.TriggerDatabase.
func (Database) RenameTable ¶
RenameTable implements the interface sql.TableRenamer.
func (Database) SaveStoredProcedure ¶
SaveStoredProcedure implements the interface sql.StoredProcedureDatabase.
type ForeignKeyHarness ¶
type ForeignKeyHarness interface { Harness // SupportsForeignKeys returns whether this harness should accept CREATE FOREIGN KEY statements as part of test // setup. SupportsForeignKeys() bool }
ForeignKeyHarness is an extension to Harness that lets an integrator test their implementation with foreign keys. Integrator tables must implement sql.ForeignKeyAlterableTable and sql.ForeignKeyTable.
type Harness ¶
type Harness interface { // Parallelism returns how many parallel go routines to use when constructing an engine for test. Parallelism() int // NewDatabase returns a sql.Database to use for a test. This method will always be called before asking for a // context or other information. NewDatabase(name string) sql.Database // NewDatabases returns a set of new databases, for test setup that requires more than one database. NewDatabases(names ...string) []sql.Database // NewDatabaseProvider returns a sql.MutableDatabaseProvider to use for a test. NewDatabaseProvider(dbs ...sql.Database) sql.MutableDatabaseProvider // NewTable takes a database previously created by NewDatabase and returns a table created with the given schema. NewTable(db sql.Database, name string, schema sql.PrimaryKeySchema) (sql.Table, error) // NewContext allows a harness to specify any sessions or context variables necessary for the proper functioning of // their engine implementation. Every harnessed engine test uses the context created by this method, with some // additional information (e.g. current DB) set uniformly. To replicated the behavior of tests during setup, // harnesses should generally dispatch to enginetest.NewContext(harness), rather than calling this method themselves. NewContext() *sql.Context }
Harness provides a way for database integrators to validate their implementation against the standard set of queries used to develop and test the engine itself. See memory_engine_test.go for an example.
type IndexDriverHarness ¶
type IndexDriverHarness interface { Harness // InitializeIndexDriver initializes the index driver for this test run with the databases given InitializeIndexDriver(dbs []sql.Database) }
IndexDriverHarness is an extension to Harness that lets an integrator test their implementation alongside an index driver they provide.
type IndexHarness ¶
type IndexHarness interface { Harness // SupportsNativeIndexCreation returns whether this harness should accept CREATE INDEX statements as part of test // setup. SupportsNativeIndexCreation() bool }
IndexHarness is an extension to Harness that lets an integrator test their implementation with native (table-supplied) indexes. Integrator tables must implement sql.IndexAlterableTable.
type KeylessTableHarness ¶
type KeylessTableHarness interface { Harness // SupportsKeylessTables indicates integrator support for keyless tables. SupportsKeylessTables() bool }
KeylessTableHarness is an extension to Harness that lets an integrator test their implementation with keyless tables.
type ReadOnlyDatabaseHarness ¶
type ReadOnlyDatabaseHarness interface { Harness // NewReadOnlyDatabases returns a []sql.ReadOnlyDatabase to use for a test. NewReadOnlyDatabases(name ...string) []sql.ReadOnlyDatabase }
type SQLITEDatabase ¶
type SQLITEDatabase struct {
// contains filtered or unexported fields
}
SQLITEDatabase represents a database for a local SQLITE server.
type SQLITEHarness ¶
type SQLITEHarness struct {
// contains filtered or unexported fields
}
SQLITEHarness is a harness for a local SQLITE server. This will modify databases and tables as the tests see fit, which may delete pre-existing data. Ensure that the SQLITE instance may freely be modified without worry.
func NewSQLITEHarness ¶
func NewSQLITEHarness(dbname string) (*SQLITEHarness, error)
NewSQLITEHarness returns a new SQLITEHarness.
func (*SQLITEHarness) Close ¶
func (m *SQLITEHarness) Close()
Close closes the connection. This will drop all databases created and accessed during the tests.
func (*SQLITEHarness) NewContext ¶
func (m *SQLITEHarness) NewContext() *sql.Context
NewContext implements the interface Harness.
func (*SQLITEHarness) NewDatabase ¶
func (m *SQLITEHarness) NewDatabase(name string) sql.Database
NewDatabase implements the interface Harness.
func (*SQLITEHarness) NewDatabaseProvider ¶
func (m *SQLITEHarness) NewDatabaseProvider(dbs ...sql.Database) sql.MutableDatabaseProvider
NewDatabaseProvider implements the interface Harness.
func (*SQLITEHarness) NewDatabases ¶
func (m *SQLITEHarness) NewDatabases(names ...string) []sql.Database
NewDatabases implements the interface Harness.
func (*SQLITEHarness) NewTable ¶
func (m *SQLITEHarness) NewTable(db sql.Database, name string, schema sql.PrimaryKeySchema) (sql.Table, error)
NewTable implements the interface Harness.
func (*SQLITEHarness) Parallelism ¶
func (m *SQLITEHarness) Parallelism() int
Parallelism implements the interface Harness.
func (*SQLITEHarness) QueriesToSkip ¶
func (m *SQLITEHarness) QueriesToSkip(queries ...string)
QueriesToSkip adds queries that should be skipped.
func (*SQLITEHarness) SkipQueryTest ¶
func (m *SQLITEHarness) SkipQueryTest(query string) bool
SkipQueryTest implements the interface SkippingHarness.
func (*SQLITEHarness) SupportsForeignKeys ¶
func (m *SQLITEHarness) SupportsForeignKeys() bool
SupportsForeignKeys implements the interface ForeignKeyHarness.
func (*SQLITEHarness) SupportsKeylessTables ¶
func (m *SQLITEHarness) SupportsKeylessTables() bool
SupportsKeylessTables implements the interface KeylessTableHarness.
func (*SQLITEHarness) SupportsNativeIndexCreation ¶
func (m *SQLITEHarness) SupportsNativeIndexCreation() bool
SupportsNativeIndexCreation implements the interface IndexHarness.
type SQLITEShim ¶
type SQLITEShim struct {
// contains filtered or unexported fields
}
SQLITEShim is a shim for a local SQLITE server. Ensure that a SQLITE instance is running prior to using this shim. Note: this may be destructive to pre-existing data, as databases and tables will be created and destroyed.
func NewSQLITEShim ¶
func NewSQLITEShim(databaseName string) (*SQLITEShim, error)
NewSQLITEShim returns a new SQLITEShim.
func (*SQLITEShim) AllDatabases ¶
func (m *SQLITEShim) AllDatabases() []sql.Database
AllDatabases implements the interface sql.MutableDatabaseProvider.
func (*SQLITEShim) Close ¶
func (m *SQLITEShim) Close()
Close closes the shim. This will drop all databases created and accessed since this shim was created.
func (*SQLITEShim) CreateDatabase ¶
func (m *SQLITEShim) CreateDatabase(ctx *sql.Context, name string) error
CreateDatabase implements the interface sql.MutableDatabaseProvider.
func (*SQLITEShim) Database ¶
func (m *SQLITEShim) Database(name string) (sql.Database, error)
Database implements the interface sql.MutableDatabaseProvider.
func (*SQLITEShim) DropDatabase ¶
func (m *SQLITEShim) DropDatabase(ctx *sql.Context, name string) error
DropDatabase implements the interface sql.MutableDatabaseProvider.
func (*SQLITEShim) Exec ¶
func (m *SQLITEShim) Exec(db string, query string) error
Exec executes the query on the connection.
func (*SQLITEShim) HasDatabase ¶
func (m *SQLITEShim) HasDatabase(name string) bool
HasDatabase implements the interface sql.MutableDatabaseProvider.
type SQLITETable ¶
type SQLITETable struct {
// contains filtered or unexported fields
}
SQLITETable represents a table for a local SQLITE server.
type SkippingHarness ¶
type SkippingHarness interface { // SkipQueryTest returns whether to skip a test of the provided query string. SkipQueryTest(query string) bool }
SkippingHarness provides a way for integrators to skip tests that are known to be broken. E.g., integrators that can't handle every possible SQL type.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents a table for a local SQLITE server.
func (Table) CreateCheck ¶
CreateCheck implements the interface sql.CheckAlterableTable.
func (Table) CreateForeignKey ¶
func (t Table) CreateForeignKey(ctx *sql.Context, fkName string, columns []string, referencedTable string, referencedColumns []string, onUpdate, onDelete sql.ForeignKeyReferenceOption) error
CreateForeignKey implements the interface sql.ForeignKeyAlterableTable.
func (Table) CreateIndex ¶
func (t Table) CreateIndex(ctx *sql.Context, indexName string, using sql.IndexUsing, constraint sql.IndexConstraint, columns []sql.IndexColumn, comment string) error
CreateIndex implements the interface sql.IndexAlterableTable.
func (Table) CreatePrimaryKey ¶
CreatePrimaryKey implements the interface sql.PrimaryKeyAlterableTable.
func (Table) DataLength ¶
DataLength implements the interface sql.StatisticsTable.
func (Table) Deleter ¶
func (t Table) Deleter(ctx *sql.Context) sql.RowDeleter
Deleter implements the interface sql.DeletableTable.
func (Table) DropColumn ¶
DropColumn implements the interface sql.AlterableTable.
func (Table) DropForeignKey ¶
DropForeignKey implements the interface sql.ForeignKeyAlterableTable.
func (Table) DropPrimaryKey ¶
DropPrimaryKey implements the interface sql.PrimaryKeyAlterableTable.
func (Table) GetForeignKeys ¶
GetForeignKeys implements the interface sql.ForeignKeyTable.
func (Table) GetIndexes ¶
GetIndexes implements the interface sql.IndexedTable.
func (Table) Inserter ¶
func (t Table) Inserter(ctx *sql.Context) sql.RowInserter
Inserter implements the interface sql.InsertableTable.
func (Table) ModifyColumn ¶
func (t Table) ModifyColumn(ctx *sql.Context, columnName string, column *sql.Column, order *sql.ColumnOrder) error
ModifyColumn implements the interface sql.AlterableTable.
func (Table) PartitionRows ¶
PartitionRows implements the interface sql.Table.
func (Table) Partitions ¶
Partitions implements the interface sql.Table.
func (Table) Pks ¶
func (t Table) Pks() []sql.IndexColumn
Pks implements sql.PrimaryKeyAlterableTable
func (Table) PrimaryKeySchema ¶
func (t Table) PrimaryKeySchema() sql.PrimaryKeySchema
PrimaryKeySchema implements sql.PrimaryKeyAlterableTable
func (Table) RenameIndex ¶
RenameIndex implements the interface sql.IndexAlterableTable.
func (Table) Replacer ¶
func (t Table) Replacer(ctx *sql.Context) sql.RowReplacer
Replacer implements the interface sql.ReplaceableTable.
func (Table) Updater ¶
func (t Table) Updater(ctx *sql.Context) sql.RowUpdater
Updater implements the interface sql.UpdatableTable.
func (Table) WithIndexLookup ¶
func (t Table) WithIndexLookup(lookup sql.IndexLookup) sql.Table
WithIndexLookup implements the interface sql.IndexAddressableTable.
type TransactionHarness ¶
type VersionedDBHarness ¶
type VersionedDBHarness interface { Harness // NewTableAsOf creates a new table with the given name and schema, optionally handling snapshotting with the asOf // identifier. NewTableAsOf must ignore tables that already exist in the database. Tables returned by this method do // not need to have any previously created data in them, but they can. This behavior is implementation specific, and // the harness works either way. NewTableAsOf(db sql.VersionedDatabase, name string, schema sql.PrimaryKeySchema, asOf interface{}) sql.Table // SnapshotTable creates a snapshot of the table named with the given asOf label. Depending on the implementation, // NewTableAsOf might do all the necessary work to create such snapshots, so this could be a no-op. SnapshotTable(db sql.VersionedDatabase, name string, asOf interface{}) error }
VersionedDBHarness is an extension to Harness that lets an integrator test their implementation of versioned (AS OF) queries. Integrators must implement sql.VersionedDatabase. For each table version being created, there will be a call to NewTableAsOf, some number of Delete and Insert operations, and then a call to SnapshotTable.