xorm: xorm.io/xorm/dialects Index | Files

package dialects

import "xorm.io/xorm/dialects"


Package Files

dialect.go driver.go filter.go mssql.go mysql.go oracle.go postgres.go quote.go sqlite3.go table_name.go time.go


var (
    // DefaultPostgresSchema default postgres schema
    DefaultPostgresSchema = "public"

func ColumnString Uses

func ColumnString(dialect Dialect, col *schemas.Column, includePrimaryKey bool) (string, error)

ColumnString generate column description string according dialect

func FormatColumnTime Uses

func FormatColumnTime(dialect Dialect, defaultTimeZone *time.Location, col *schemas.Column, t time.Time) (v interface{})

func FormatTime Uses

func FormatTime(dialect Dialect, sqlTypeName string, t time.Time) (v interface{})

FormatTime format time as column type

func FullTableName Uses

func FullTableName(dialect Dialect, mapper names.Mapper, bean interface{}, includeSchema ...bool) string

FullTableName returns table name with quote and schema according parameter

func QueryDefaultPostgresSchema Uses

func QueryDefaultPostgresSchema(ctx context.Context, queryer core.Queryer) (string, error)

QueryDefaultPostgresSchema returns the default postgres schema

func RegisterDialect Uses

func RegisterDialect(dbName schemas.DBType, dialectFunc func() Dialect)

RegisterDialect register database dialect

func RegisterDriver Uses

func RegisterDriver(driverName string, driver Driver)

func RegisteredDriverSize Uses

func RegisteredDriverSize() int

func TableNameNoSchema Uses

func TableNameNoSchema(dialect Dialect, mapper names.Mapper, tableName interface{}) string

TableNameNoSchema returns table name with given tableName

func TableNameWithSchema Uses

func TableNameWithSchema(dialect Dialect, tableName string) string

TableNameWithSchema will add schema prefix on table name if possible

type Base Uses

type Base struct {
    // contains filtered or unexported fields

Base represents a basic dialect and all real dialects could embed this struct

func (*Base) AddColumnSQL Uses

func (db *Base) AddColumnSQL(tableName string, col *schemas.Column) string

func (*Base) CreateIndexSQL Uses

func (db *Base) CreateIndexSQL(tableName string, index *schemas.Index) string

func (*Base) DBType Uses

func (b *Base) DBType() schemas.DBType

func (*Base) DropIndexSQL Uses

func (db *Base) DropIndexSQL(tableName string, index *schemas.Index) string

func (*Base) DropTableSQL Uses

func (db *Base) DropTableSQL(tableName string) (string, bool)

func (*Base) ForUpdateSQL Uses

func (b *Base) ForUpdateSQL(query string) string

func (*Base) FormatBytes Uses

func (b *Base) FormatBytes(bs []byte) string

func (*Base) HasRecords Uses

func (db *Base) HasRecords(queryer core.Queryer, ctx context.Context, query string, args ...interface{}) (bool, error)

func (*Base) Init Uses

func (b *Base) Init(dialect Dialect, uri *URI) error

func (*Base) IsColumnExist Uses

func (db *Base) IsColumnExist(queryer core.Queryer, ctx context.Context, tableName, colName string) (bool, error)

func (*Base) ModifyColumnSQL Uses

func (db *Base) ModifyColumnSQL(tableName string, col *schemas.Column) string

func (*Base) Quoter Uses

func (b *Base) Quoter() schemas.Quoter

func (*Base) SetParams Uses

func (b *Base) SetParams(params map[string]string)

func (*Base) URI Uses

func (b *Base) URI() *URI

type Dialect Uses

type Dialect interface {
    Init(*URI) error
    URI() *URI
    SQLType(*schemas.Column) string
    FormatBytes(b []byte) string

    IsReserved(string) bool
    Quoter() schemas.Quoter
    SetQuotePolicy(quotePolicy QuotePolicy)

    AutoIncrStr() string

    GetIndexes(queryer core.Queryer, ctx context.Context, tableName string) (map[string]*schemas.Index, error)
    IndexCheckSQL(tableName, idxName string) (string, []interface{})
    CreateIndexSQL(tableName string, index *schemas.Index) string
    DropIndexSQL(tableName string, index *schemas.Index) string

    GetTables(queryer core.Queryer, ctx context.Context) ([]*schemas.Table, error)
    IsTableExist(queryer core.Queryer, ctx context.Context, tableName string) (bool, error)
    CreateTableSQL(table *schemas.Table, tableName string) ([]string, bool)
    DropTableSQL(tableName string) (string, bool)

    GetColumns(queryer core.Queryer, ctx context.Context, tableName string) ([]string, map[string]*schemas.Column, error)
    IsColumnExist(queryer core.Queryer, ctx context.Context, tableName string, colName string) (bool, error)
    AddColumnSQL(tableName string, col *schemas.Column) string
    ModifyColumnSQL(tableName string, col *schemas.Column) string

    ForUpdateSQL(query string) string

    Filters() []Filter
    SetParams(params map[string]string)

Dialect represents a kind of database

func OpenDialect Uses

func OpenDialect(driverName, connstr string) (Dialect, error)

OpenDialect opens a dialect via driver name and connection string

func QueryDialect Uses

func QueryDialect(dbName schemas.DBType) Dialect

QueryDialect query if registered database dialect

type Driver Uses

type Driver interface {
    Parse(string, string) (*URI, error)

func QueryDriver Uses

func QueryDriver(driverName string) Driver

type Filter Uses

type Filter interface {
    Do(sql string) string

Filter is an interface to filter SQL

type QuotePolicy Uses

type QuotePolicy int

QuotePolicy describes quote handle policy

const (
    QuotePolicyAlways QuotePolicy = iota

All QuotePolicies

type SeqFilter Uses

type SeqFilter struct {
    Prefix string
    Start  int

SeqFilter filter SQL replace ?, ? ... to $1, $2 ...

func (*SeqFilter) Do Uses

func (s *SeqFilter) Do(sql string) string

type URI Uses

type URI struct {
    DBType  schemas.DBType
    Proto   string
    Host    string
    Port    string
    DBName  string
    User    string
    Passwd  string
    Charset string
    Laddr   string
    Raddr   string
    Timeout time.Duration
    Schema  string

URI represents an uri to visit database

func (*URI) SetSchema Uses

func (uri *URI) SetSchema(schema string)

SetSchema set schema

Package dialects imports 15 packages (graph) and is imported by 8 packages. Updated 2021-01-22. Refresh now. Tools for package owners.