driver

package
v1.2205.0-pre1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2022 License: MPL-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adaptor

type Adaptor struct {
	// contains filtered or unexported fields
}

Adaptor is a wrapper for the sqle driver layer. It provides a more simpler interface for the database plugin.

func NewAdaptor

func NewAdaptor(dt Dialector) *Adaptor

NewAdaptor create a database plugin Adaptor with dialector.

func (*Adaptor) AddAdditionalParams added in v1.2203.0

func (a *Adaptor) AddAdditionalParams(p *params.Param)

func (*Adaptor) AddRule

func (a *Adaptor) AddRule(r *driver.Rule, h rawSQLRuleHandler)

func (*Adaptor) AddRuleWithSQLParser

func (a *Adaptor) AddRuleWithSQLParser(r *driver.Rule, h astSQLRuleHandler)

func (*Adaptor) Serve

func (a *Adaptor) Serve(opts ...AdaptorOption)

type AdaptorOption

type AdaptorOption interface {
	// contains filtered or unexported methods
}

AdaptorOption store some custom options for the driver adaptor.

func WithSQLParser

func WithSQLParser(parser func(sql string) (ast interface{}, err error)) AdaptorOption

WithSQLParser define custom SQL parser. If set, the adaptor will use it to parse the SQL. User can assert the SQL to correspond ast structure in ruleHandler.

type Dialector

type Dialector interface {
	// Dialect return the driver name and dsn detail. The return value is used for sql.Open().
	Dialect(dsn *driver.DSN) (driverName string, dsnDetail string)

	// ShowDatabaseSQL return the sql to show all databases.
	ShowDatabaseSQL() string

	// String return the dialect name with more formal name. It is different from driver name.
	// For example, "PostgreSQL" is more formal name than "pgx".
	String() string
}

Dialector is a interface for database dialect. It used for sql.Open()

type MssqlDialector

type MssqlDialector struct {
}

func (*MssqlDialector) Dialect

func (d *MssqlDialector) Dialect(dsn *driver.DSN) (string, string)

func (*MssqlDialector) ShowDatabaseSQL

func (d *MssqlDialector) ShowDatabaseSQL() string

func (*MssqlDialector) String

func (d *MssqlDialector) String() string

type OracleDialector

type OracleDialector struct {
}

func (*OracleDialector) Dialect

func (d *OracleDialector) Dialect(dsn *driver.DSN) (string, string)

func (*OracleDialector) ShowDatabaseSQL

func (d *OracleDialector) ShowDatabaseSQL() string

func (*OracleDialector) String

func (d *OracleDialector) String() string

type PostgresDialector

type PostgresDialector struct {
}

func (*PostgresDialector) Dialect

func (d *PostgresDialector) Dialect(dsn *driver.DSN) (string, string)

func (*PostgresDialector) ShowDatabaseSQL

func (d *PostgresDialector) ShowDatabaseSQL() string

func (*PostgresDialector) String

func (d *PostgresDialector) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL