grammar

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 5 Imported by: 2

Documentation

Overview

Package grammar generates SQL statements described by a configured grammar.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTableRequired   error = errors.New("table name is required")
	ErrColumnsRequired error = errors.New("columns are required")
	ErrKeysRequired    error = errors.New("keys are required")
)

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.

Jump to

Keyboard shortcuts

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