github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/depends/kit/sqlx/builder/builder.go (about)

     1  package builder
     2  
     3  import (
     4  	"database/sql/driver"
     5  	"reflect"
     6  )
     7  
     8  type Model interface {
     9  	TableName() string
    10  }
    11  
    12  type WithPrimaryKey interface {
    13  	PrimaryKey() []string
    14  }
    15  
    16  type WithUniqueIndexes interface {
    17  	UniqueIndexes() Indexes
    18  }
    19  
    20  type WithIndexes interface {
    21  	Indexes() Indexes
    22  }
    23  
    24  type WithComments interface {
    25  	Comments() map[string]string
    26  }
    27  
    28  type WithTableDesc interface {
    29  	TableDesc() []string
    30  }
    31  
    32  type WithColDesc interface {
    33  	ColDesc() map[string][]string
    34  }
    35  
    36  type WithColRel interface {
    37  	ColRel() map[string][]string
    38  }
    39  
    40  type Indexes map[string][]string
    41  
    42  var (
    43  	RtModel        = reflect.TypeOf((*Model)(nil)).Elem()
    44  	RtDriverValuer = reflect.TypeOf((*driver.Valuer)(nil)).Elem()
    45  )
    46  
    47  type Dialect interface {
    48  	DriverName() string
    49  	PrimaryKeyName() string
    50  	IsErrorUnknownDatabase(error) bool
    51  	IsErrorConflict(error) bool
    52  	CreateDatabase(string) SqlExpr
    53  	CreateSchema(string) SqlExpr
    54  	DropDatabase(string) SqlExpr
    55  	CreateTableIsNotExists(t *Table) []SqlExpr
    56  	DropTable(*Table) SqlExpr
    57  	TruncateTable(*Table) SqlExpr
    58  	AddColumn(*Column) SqlExpr
    59  	RenameColumn(*Column, *Column) SqlExpr
    60  	ModifyColumn(*Column, *Column) SqlExpr
    61  	DropColumn(*Column) SqlExpr
    62  	AddIndex(*Key) SqlExpr
    63  	DropIndex(*Key) SqlExpr
    64  	DataType(*ColumnType) SqlExpr
    65  }
    66  
    67  type DataTypeDescriber interface {
    68  	DataType(driver string) string
    69  }