Documentation ¶
Overview ¶
Package grammar generates SQL statements described by a configured grammar.
Index ¶
- Variables
- type Grammar
- type PostgresGrammar
- func (me *PostgresGrammar) Delete(table string, keys []string) (*statements.Query, error)
- func (me *PostgresGrammar) Insert(table string, columns []string, auto []string) (*statements.Query, error)
- func (me *PostgresGrammar) ParamN(n int) string
- func (me *PostgresGrammar) Update(table string, columns []string, keys []string, auto []string) (*statements.Query, error)
- func (me *PostgresGrammar) Upsert(table string, columns []string, keys []string, auto []string) (*statements.Query, error)
- type SqliteGrammar
- func (me *SqliteGrammar) Delete(table string, keys []string) (*statements.Query, error)
- func (me *SqliteGrammar) Insert(table string, columns []string, auto []string) (*statements.Query, error)
- func (me *SqliteGrammar) Update(table string, columns []string, keys []string, auto []string) (*statements.Query, error)
- func (me *SqliteGrammar) Upsert(table string, columns []string, keys []string, auto []string) (*statements.Query, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Grammar ¶
type Grammar interface { // Delete returns the query type for deleting from the table. Delete(table string, keys []string) (*statements.Query, error) // Insert returns the query type for inserting into table. Insert(table string, columns []string, auto []string) (*statements.Query, error) // Update returns the query type for updating a record in a table. Update(table string, columns []string, keys []string, auto []string) (*statements.Query, error) // Upsert returns the query type for upserting (INSERT|UPDATE) a record in a table. Upsert(table string, columns []string, keys []string, auto []string) (*statements.Query, error) }
Grammar creates SQL queries for a specific database engine.
var Postgres Grammar = &PostgresGrammar{}
Postgres is an instantiated grammar for PostgreSQL.
var Sqlite Grammar = &SqliteGrammar{}
Sqlite is an instantiated grammar for SQLite.
type PostgresGrammar ¶ added in v0.3.0
type PostgresGrammar struct { }
PostgresGrammar defines a grammar for Postgres.
func (*PostgresGrammar) Delete ¶ added in v0.3.0
func (me *PostgresGrammar) Delete(table string, keys []string) (*statements.Query, error)
Delete returns the query type for deleting from the table.
func (*PostgresGrammar) Insert ¶ added in v0.3.0
func (me *PostgresGrammar) Insert(table string, columns []string, auto []string) (*statements.Query, error)
Insert returns the query type for inserting into table.
func (*PostgresGrammar) ParamN ¶ added in v0.3.0
func (me *PostgresGrammar) ParamN(n int) string
ParamN returns the string for parameter N where N is zero-based and return value is one-based.
func (*PostgresGrammar) Update ¶ added in v0.3.0
func (me *PostgresGrammar) Update(table string, columns []string, keys []string, auto []string) (*statements.Query, error)
Update returns the query type for updating a record in a table.
func (*PostgresGrammar) Upsert ¶ added in v0.3.0
func (me *PostgresGrammar) Upsert(table string, columns []string, keys []string, auto []string) (*statements.Query, error)
Upsert returns the query type for upserting (INSERT|UPDATE) a record in a table.
type SqliteGrammar ¶ added in v0.3.0
type SqliteGrammar struct { }
SqliteGrammar defines a grammar for SQLite v2.35+.
func (*SqliteGrammar) Delete ¶ added in v0.3.0
func (me *SqliteGrammar) Delete(table string, keys []string) (*statements.Query, error)
Delete returns the query type for deleting from the table.
func (*SqliteGrammar) Insert ¶ added in v0.3.0
func (me *SqliteGrammar) Insert(table string, columns []string, auto []string) (*statements.Query, error)
Insert returns the query type for inserting into table.
func (*SqliteGrammar) Update ¶ added in v0.3.0
func (me *SqliteGrammar) Update(table string, columns []string, keys []string, auto []string) (*statements.Query, error)
Update returns the query type for updating a record in a table.
func (*SqliteGrammar) Upsert ¶ added in v0.3.0
func (me *SqliteGrammar) Upsert(table string, columns []string, keys []string, auto []string) (*statements.Query, error)
Upsert returns the query type for upserting (INSERT|UPDATE) a record in a table.