Documentation
¶
Overview ¶
Package sqlgen is the logic for generating different kinds of SQL statements.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUKColValueNotProvided means that some column values of the unique key are not provided. ErrUKColValueNotProvided = errors.New("some UK column values are not provided") // ErrMissingUKValue means the input unique key is nil. ErrMissingUKValue = errors.New("missing the UK values") // ErrWhereConditionsEmpty means the WHERE clause compare conditions is empty. // It is usually caused when there is no filter clause generated on generating a WHERE clause. ErrWhereFiltersEmpty = errors.New("`WHERE` condition filters is empty") )
Functions ¶
func NewSQLGeneratorImpl ¶
func NewSQLGeneratorImpl(tableConfig *config.TableConfig) *sqlGeneratorImpl
NewSQLGeneratorImpl generates a new implementation object for SQL generator.
Types ¶
type SQLGenerator ¶
type SQLGenerator interface {
// GenTruncateTable generates a TRUNCATE TABLE SQL.
GenTruncateTable() (string, error)
// GenLoadUniqueKeySQL generates a SELECT SQL fetching all the uniques of a table.
// The column definitions of the returned data is also provided,
// so that the values can be stored to different variables.
GenLoadUniqueKeySQL() (string, []*config.ColumnDefinition, error)
// GenInsertRow generates an INSERT SQL.
// The new row's unique key is also provided,
// so that it can be further added into an MCP.
GenInsertRow() (string, *mcp.UniqueKey, error)
// GenUpdateRow generates an UPDATE SQL for the given unique key.
GenUpdateRow(*mcp.UniqueKey) (string, error)
// GenDeleteRow generates a DELETE SQL for the given unique key.
GenDeleteRow(*mcp.UniqueKey) (string, error)
// GenCreateTable generates a CreateTable SQL by table config.
GenCreateTable() string
}
SQLGenerator contains all the operations for generating SQLs.
Click to show internal directories.
Click to hide internal directories.