sql

package
v0.0.0-...-5eee607 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Expr  string
	Alias string
}

A Column represents a selected expression in a SQL query and its alias.

func (*Column) SQL

func (c *Column) SQL() string

SQL gets the SQL expression for the column expression with its optional alias.

type Select

type Select struct {
	Columns    []*Column
	TableExprs []*TableExpr
}

A Select represents a SQL select statement with a list of columns to select and a list of tables being selected from.

func (*Select) AddAliasedColumn

func (q *Select) AddAliasedColumn(expr, alias string) *Column

AddAliasedColumn adds expr as a selected column with alias.

func (*Select) AddColumn

func (q *Select) AddColumn(col *Column) *Column

AddColumn adds col as a column.

func (*Select) AddColumnExpr

func (q *Select) AddColumnExpr(expr string) *Column

AddColumnExpr adds expr as a selected column.

func (*Select) AddJoinTable

func (q *Select) AddJoinTable(table *Table, joinExpr string, joinType string) *TableExpr

AddJoinTable adds table as a join table with joinExpr as the join condition and joinType specifying the type of join.

func (*Select) AddNamedAliasedTable

func (q *Select) AddNamedAliasedTable(name, alias string) *TableExpr

AddNamedAliasedTable adds name as a selected table with a table alias.

func (*Select) AddNamedTable

func (q *Select) AddNamedTable(name string) *TableExpr

AddNamedTable adds name as a selected table.

func (*Select) AddTable

func (q *Select) AddTable(table *Table) *TableExpr

AddTable adds table as a selected table.

func (*Select) AddTableExpr

func (q *Select) AddTableExpr(expr *TableExpr) *TableExpr

AddTableExpr adds expr as a joined table expression.

func (*Select) ColumnSQL

func (q *Select) ColumnSQL() string

ColumnSQL gets the SQL fragment for the columns being selected.

func (*Select) FromClauses

func (q *Select) FromClauses() string

FromClauses gets the SQL FROM clauses for this query.

func (*Select) SQL

func (q *Select) SQL() string

SQL gets the query SQL as a string

type Table

type Table struct {
	Name  string
	Expr  *Select
	Alias string
}

A Table is a SQL query fragment referencing a single table.

func (*Table) EffectiveAlias

func (t *Table) EffectiveAlias() string

EffectiveAlias gets the alias for this table in the broader query. If no explicit alias has been specified, returns the table name itself.

func (*Table) QualifiedName

func (t *Table) QualifiedName(name string) string

QualifiedName qualifies the column name with the table's query alias.

func (*Table) SQL

func (t *Table) SQL() string

SQL ges the SQL clause for this query fragment.

func (*Table) SimpleTable

func (t *Table) SimpleTable() bool

SimpleTable returns true if there are no explicit columns selected from this table, viz. a simple reference to the underlying table.

type TableExpr

type TableExpr struct {
	*Table
	JoinType       string
	JoinConditions string
}

A TableExpr specifies a table and its join relationship to the set of existing tables in the query.

func (*TableExpr) JoinSQL

func (t *TableExpr) JoinSQL() string

JoinSQL gets the SQL join clause for this joined table.

Jump to

Keyboard shortcuts

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