Documentation
¶
Index ¶
- Variables
- func DBErr(err error) *dbErr
- func Scan(rows *sql.Rows, v interface{}) error
- func SyncEnum(database *Database, db *DB) error
- type ColumnSchema
- type DB
- func (d *DB) Begin() (*DB, error)
- func (d *DB) Commit() error
- func (d *DB) Exec(query string, args ...interface{}) (sql.Result, error)
- func (d *DB) ExecExpr(expr builder.SqlExpr) (sql.Result, error)
- func (d *DB) IsTx() bool
- func (d *DB) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (d *DB) QueryExpr(expr builder.SqlExpr) (*sql.Rows, error)
- func (d *DB) QueryExprAndScan(expr builder.SqlExpr, v interface{}) error
- func (d *DB) Rollback() error
- func (d *DB) SetConnMaxLifetime(t time.Duration)
- func (d *DB) SetMaxIdleConns(n int)
- func (d *DB) SetMaxOpenConns(n int)
- type Database
- func (database *Database) Assignments(model builder.Model, excludes ...string) builder.Assignments
- func (database *Database) MigrateTo(db *DB, opts MigrationOptions) error
- func (database *Database) Register(model builder.Model) *builder.Table
- func (database Database) T(model builder.Model) *builder.Table
- type IndexSchema
- type MigrationOptions
- type Schema
- type SqlError
- type SqlExecutor
- type SqlMetaEnum
- type TableSchema
- type Task
- type Tasks
Constants ¶
This section is empty.
Variables ¶
View Source
var DuplicateEntryErrNumber uint16 = 1062
View Source
var ErrNotDB = errors.New("db is not *sql.DB")
View Source
var ErrNotTx = errors.New("db is not *sql.Tx")
View Source
var SchemaDatabase = NewDatabase("INFORMATION_SCHEMA")
Functions ¶
Types ¶
type ColumnSchema ¶
type ColumnSchema struct {
TABLE_SCHEMA string `db:"TABLE_SCHEMA" sql:"varchar(64) NOT NULL DEFAULT ''"`
TABLE_NAME string `db:"TABLE_NAME" sql:"varchar(64) NOT NULL DEFAULT ''"`
COLUMN_NAME string `db:"COLUMN_NAME" sql:"varchar(64) NOT NULL DEFAULT ''"`
ORDINAL_POSITION int32 `db:"ORDINAL_POSITION" sql:"bigint(21) unsigned NOT NULL DEFAULT '0'"`
COLUMN_DEFAULT sql.NullString `db:"COLUMN_DEFAULT" sql:"longtext"`
IS_NULLABLE string `db:"IS_NULLABLE" sql:"varchar(3) NOT NULL DEFAULT ''"`
DATA_TYPE string `db:"DATA_TYPE" sql:"varchar(64) NOT NULL DEFAULT ''"`
CHARACTER_MAXIMUM_LENGTH sql.NullInt64 `db:"CHARACTER_MAXIMUM_LENGTH" sql:"bigint(21) unsigned DEFAULT NULL"`
CHARACTER_OCTET_LENGTH sql.NullInt64 `db:"CHARACTER_OCTET_LENGTH" sql:"bigint(21) unsigned DEFAULT NULL"`
NUMERIC_PRECISION sql.NullInt64 `db:"NUMERIC_PRECISION" sql:"bigint(21) unsigned DEFAULT NULL"`
NUMERIC_SCALE sql.NullInt64 `db:"NUMERIC_SCALE" sql:"bigint(21) unsigned DEFAULT NULL"`
DATETIME_PRECISION sql.NullInt64 `db:"DATETIME_PRECISION" sql:"bigint(21) unsigned DEFAULT NULL"`
CHARACTER_SET_NAME sql.NullString `db:"CHARACTER_SET_NAME" sql:"varchar(32) DEFAULT NULL"`
COLLATION_NAME sql.NullString `db:"COLLATION_NAME" sql:"varchar(32) DEFAULT NULL"`
COLUMN_TYPE string `db:"COLUMN_TYPE" sql:"longtext NOT NULL"`
COLUMN_KEY string `db:"COLUMN_KEY" sql:"varchar(3) NOT NULL DEFAULT ''"`
EXTRA string `db:"EXTRA" sql:"varchar(30) NOT NULL DEFAULT ''"`
PRIVILEGES string `db:"PRIVILEGES" sql:"varchar(80) NOT NULL DEFAULT ''"`
COLUMN_COMMENT string `db:"COLUMN_COMMENT" sql:"varchar(1024) NOT NULL DEFAULT ''"`
}
func (ColumnSchema) TableName ¶
func (columnSchema ColumnSchema) TableName() string
func (ColumnSchema) ToColumnType ¶
func (columnSchema ColumnSchema) ToColumnType() *datatypes.ColumnType
type DB ¶
type DB struct {
SqlExecutor
}
func (*DB) QueryExprAndScan ¶
func (*DB) SetConnMaxLifetime ¶
func (*DB) SetMaxIdleConns ¶
func (*DB) SetMaxOpenConns ¶
type Database ¶
func DBFromInformationSchema ¶
func NewDatabase ¶
func NewFeatureDatabase ¶
func (*Database) Assignments ¶
type IndexSchema ¶
type IndexSchema struct {
TABLE_SCHEMA string `db:"TABLE_SCHEMA" sql:"varchar(64) NOT NULL DEFAULT ''"`
TABLE_NAME string `db:"TABLE_NAME" sql:"varchar(64) NOT NULL DEFAULT ''"`
NON_UNIQUE int32 `db:"NON_UNIQUE" sql:"bigint(1) NOT NULL DEFAULT '0'"`
INDEX_SCHEMA string `db:"INDEX_SCHEMA" sql:"varchar(64) NOT NULL DEFAULT ''"`
INDEX_NAME string `db:"INDEX_NAME" sql:"varchar(64) NOT NULL DEFAULT ''"`
SEQ_IN_INDEX int32 `db:"SEQ_IN_INDEX" sql:"bigint(2) NOT NULL DEFAULT '0'"`
COLUMN_NAME string `db:"COLUMN_NAME" sql:"varchar(64) NOT NULL DEFAULT ''"`
COLLATION sql.NullString `db:"COLLATION" sql:"varchar(1) DEFAULT NULL"`
CARDINALITY sql.NullInt64 `db:"CARDINALITY" sql:"bigint(21) DEFAULT NULL"`
SUB_PART sql.NullInt64 `db:"SUB_PART" sql:"bigint(3) DEFAULT NULL"`
PACKED sql.NullString `db:"PACKED" sql:"varchar(10) DEFAULT NULL"`
NULLABLE string `db:"NULLABLE" sql:"varchar(3) NOT NULL DEFAULT ''"`
INDEX_TYPE string `db:"INDEX_TYPE" sql:"varchar(16) NOT NULL DEFAULT ''"`
COMMENT string `db:"COMMENT" sql:"varchar(16) DEFAULT NULL"`
INDEX_COMMENT string `db:"INDEX_COMMENT" sql:"varchar(1024) NOT NULL DEFAULT ''"`
}
func (IndexSchema) TableName ¶
func (indexSchema IndexSchema) TableName() string
type MigrationOptions ¶
type Schema ¶
type Schema struct {
SCHEMA_NAME string `db:"SCHEMA_NAME" sql:"varchar(64) NOT NULL DEFAULT ''"`
}
type SqlExecutor ¶
type SqlMetaEnum ¶
type SqlMetaEnum struct {
TName string `db:"F_table_name" sql:"varchar(64) NOT NULL"`
CName string `db:"F_column_name" sql:"varchar(64) NOT NULL"`
Value int `db:"F_value" sql:"int NOT NULL"`
Type string `db:"F_type" sql:"varchar(255) NOT NULL"`
Key string `db:"F_key" sql:"varchar(255) NOT NULL"`
Label string `db:"F_label" sql:"varchar(255) NOT NULL"`
}
func (*SqlMetaEnum) TableName ¶
func (*SqlMetaEnum) TableName() string
func (*SqlMetaEnum) UniqueIndexes ¶
func (*SqlMetaEnum) UniqueIndexes() builder.Indexes
type TableSchema ¶
type TableSchema struct {
TABLE_SCHEMA string `db:"TABLE_SCHEMA" sql:"varchar(64) NOT NULL DEFAULT ''"`
TABLE_NAME string `db:"TABLE_NAME" sql:"varchar(64) NOT NULL DEFAULT ''"`
TABLE_TYPE string `db:"TABLE_TYPE" sql:"varchar(64) NOT NULL DEFAULT ''"`
ENGINE sql.NullString `db:"ENGINE" sql:"varchar(64) DEFAULT NULL"`
VERSION sql.NullInt64 `db:"VERSION" sql:"bigint(21) unsigned DEFAULT NULL"`
ROW_FORMAT sql.NullString `db:"ROW_FORMAT" sql:"varchar(10) DEFAULT NULL"`
TABLE_ROWS sql.NullInt64 `db:"TABLE_ROWS" sql:"bigint(21) unsigned DEFAULT NULL"`
AVG_ROW_LENGTH sql.NullInt64 `db:"AVG_ROW_LENGTH" sql:"bigint(21) unsigned DEFAULT NULL"`
DATA_LENGTH sql.NullInt64 `db:"DATA_LENGTH" sql:"bigint(21) unsigned DEFAULT NULL"`
MAX_DATA_LENGTH sql.NullInt64 `db:"MAX_DATA_LENGTH" sql:"bigint(21) unsigned DEFAULT NULL"`
INDEX_LENGTH sql.NullInt64 `db:"INDEX_LENGTH" sql:"bigint(21) unsigned DEFAULT NULL"`
DATA_FREE sql.NullInt64 `db:"DATA_FREE" sql:"bigint(21) unsigned DEFAULT NULL"`
AUTO_INCREMENT sql.NullString `db:"AUTO_INCREMENT" sql:"bigint(21) unsigned DEFAULT NULL"`
CREATE_TIME time.Time `db:"CREATE_TIME" sql:"datetime DEFAULT NULL"`
UPDATE_TIME time.Time `db:"UPDATE_TIME" sql:"datetime DEFAULT NULL"`
CHECK_TIME time.Time `db:"CHECK_TIME" sql:"datetime DEFAULT NULL"`
TABLE_COLLATION sql.NullString `db:"TABLE_COLLATION" sql:"varchar(32) DEFAULT NULL"`
CHECKSUM sql.NullInt64 `db:"CHECKSUM" sql:"bigint(21) unsigned DEFAULT NULL"`
CREATE_OPTIONS sql.NullString `db:"CREATE_OPTIONS" sql:"varchar(255) DEFAULT NULL"`
TABLE_COMMENT string `db:"TABLE_COMMENT" sql:"varchar(2048) NOT NULL DEFAULT ''"`
}
func (TableSchema) TableName ¶
func (tableSchema TableSchema) TableName() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.