Documentation ¶
Index ¶
- Variables
- type Buffer
- func (b *Buffer) AddArguments(args ...any)
- func (b Buffer) Arguments() []any
- func (b *Buffer) Reset()
- func (b *Buffer) WriteEscape(value string)
- func (b *Buffer) WriteField(table, field string)
- func (b *Buffer) WritePlaceholder()
- func (b *Buffer) WriteTable(table string)
- func (b *Buffer) WriteValue(value any)
- type BufferFactory
- type ColumnMapper
- type ColumnOptionsMapper
- type DefinitionFilter
- type Delete
- type DropKeyMapper
- type Filter
- func (f Filter) Write(buffer *Buffer, table string, filter rel.FilterQuery, queryWriter QueryWriter)
- func (f Filter) WriteComparison(buffer *Buffer, table string, filter rel.FilterQuery, queryWriter QueryWriter)
- func (f Filter) WriteInclusion(buffer *Buffer, table string, filter rel.FilterQuery, queryWriter QueryWriter)
- func (f Filter) WriteInclusionValues(buffer *Buffer, values []any, queryWriter QueryWriter)
- func (f Filter) WriteLogical(buffer *Buffer, table, op string, inner []rel.FilterQuery, ...)
- func (f Filter) WriteSubQuery(buffer *Buffer, sub rel.SubQuery, queryWriter QueryWriter)
- type Index
- type Insert
- func (i Insert) Build(table string, primaryField string, mutates map[string]rel.Mutate, ...) (string, []any)
- func (i Insert) WriteInsertInto(buffer *Buffer, table string)
- func (i Insert) WriteReturning(buffer *Buffer, primaryField string)
- func (i Insert) WriteValues(buffer *Buffer, mutates map[string]rel.Mutate)
- type InsertAll
- func (ia InsertAll) Build(table string, primaryField string, fields []string, ...) (string, []any)
- func (ia InsertAll) WriteInsertInto(buffer *Buffer, table string)
- func (ia InsertAll) WriteReturning(buffer *Buffer, primaryField string)
- func (ia InsertAll) WriteValues(buffer *Buffer, fields []string, bulkMutates []map[string]rel.Mutate)
- type OnConflict
- func (oc OnConflict) Write(buffer *Buffer, fields []string, onConflict rel.OnConflict)
- func (oc OnConflict) WriteIgnore(buffer *Buffer, fields []string)
- func (oc OnConflict) WriteKeys(buffer *Buffer, onConflict rel.OnConflict)
- func (oc OnConflict) WriteMutates(buffer *Buffer, mutates map[string]rel.Mutate, onConflict rel.OnConflict)
- func (oc OnConflict) WriteReplace(buffer *Buffer, fields []string)
- type Query
- func (q Query) Build(query rel.Query) (string, []any)
- func (q Query) Write(buffer *Buffer, query rel.Query)
- func (q Query) WriteFrom(buffer *Buffer, table string)
- func (q Query) WriteGroupBy(buffer *Buffer, table string, fields []string)
- func (q Query) WriteHaving(buffer *Buffer, table string, filter rel.FilterQuery)
- func (q Query) WriteJoin(buffer *Buffer, table string, joins []rel.JoinQuery)
- func (q Query) WriteLimitOffset(buffer *Buffer, limit rel.Limit, offset rel.Offset)
- func (q Query) WriteOrderBy(buffer *Buffer, table string, orders []rel.SortQuery)
- func (q Query) WriteQuery(buffer *Buffer, query rel.Query)
- func (q Query) WriteSelect(buffer *Buffer, table string, selectQuery rel.SelectQuery)
- func (q Query) WriteWhere(buffer *Buffer, table string, filter rel.FilterQuery)
- type QueryWriter
- type Quote
- type Quoter
- type Table
- func (t Table) Build(table rel.Table) string
- func (t Table) WriteAlterTable(buffer *Buffer, table rel.Table)
- func (t Table) WriteColumn(buffer *Buffer, column rel.Column)
- func (t Table) WriteCreateTable(buffer *Buffer, table rel.Table)
- func (t Table) WriteDropTable(buffer *Buffer, table rel.Table)
- func (t Table) WriteKey(buffer *Buffer, key rel.Key)
- func (t Table) WriteOptions(buffer *Buffer, options string)
- func (t Table) WriteRenameTable(buffer *Buffer, table rel.Table)
- type Update
Constants ¶
This section is empty.
Variables ¶
var UnescapeCharacter byte = '^'
UnescapeCharacter disable field escaping when it starts with this character.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct { strings.Builder Quoter Quoter ValueConverter driver.ValueConverter ArgumentPlaceholder string AllowTableSchema bool ArgumentOrdinal bool InlineValues bool BoolTrueValue string BoolFalseValue string // contains filtered or unexported fields }
Buffer is used to build query string.
func (*Buffer) AddArguments ¶
func (b *Buffer) AddArguments(args ...any)
AddArguments appends multiple arguments without writing placeholder query..
func (*Buffer) WriteField ¶ added in v0.3.0
WriteField writes table and field name.
func (*Buffer) WritePlaceholder ¶
func (b *Buffer) WritePlaceholder()
WritePlaceholder without adding argument. argument can be added later using AddArguments function.
func (*Buffer) WriteTable ¶ added in v0.15.0
WriteTable writes table name.
func (*Buffer) WriteValue ¶
func (b *Buffer) WriteValue(value any)
WriteValue query placeholder and append value to argument.
type BufferFactory ¶
type BufferFactory struct { Quoter Quoter ValueConverter driver.ValueConverter AllowTableSchema bool ArgumentPlaceholder string ArgumentOrdinal bool InlineValues bool BoolTrueValue string BoolFalseValue string }
BufferFactory is used to create buffer based on shared settings.
func (BufferFactory) Create ¶
func (bf BufferFactory) Create() Buffer
type ColumnOptionsMapper ¶ added in v0.16.0
type DefinitionFilter ¶ added in v0.13.0
type DefinitionFilter func(table rel.Table, def rel.TableDefinition) bool
type Delete ¶
type Delete struct { BufferFactory BufferFactory Query QueryWriter Filter Filter }
Delete builder.
type DropKeyMapper ¶ added in v0.14.0
type Filter ¶
type Filter struct{}
Filter builder.
func (Filter) Write ¶
func (f Filter) Write(buffer *Buffer, table string, filter rel.FilterQuery, queryWriter QueryWriter)
Write SQL to buffer.
func (Filter) WriteComparison ¶ added in v0.9.0
func (f Filter) WriteComparison(buffer *Buffer, table string, filter rel.FilterQuery, queryWriter QueryWriter)
WriteComparison SQL to buffer.
func (Filter) WriteInclusion ¶ added in v0.9.0
func (f Filter) WriteInclusion(buffer *Buffer, table string, filter rel.FilterQuery, queryWriter QueryWriter)
WriteInclusion SQL to buffer.
func (Filter) WriteInclusionValues ¶ added in v0.9.0
func (f Filter) WriteInclusionValues(buffer *Buffer, values []any, queryWriter QueryWriter)
func (Filter) WriteLogical ¶ added in v0.9.0
func (f Filter) WriteLogical(buffer *Buffer, table, op string, inner []rel.FilterQuery, queryWriter QueryWriter)
WriteLogical SQL to buffer.
func (Filter) WriteSubQuery ¶ added in v0.9.0
func (f Filter) WriteSubQuery(buffer *Buffer, sub rel.SubQuery, queryWriter QueryWriter)
type Index ¶
type Index struct { BufferFactory BufferFactory Query QueryWriter Filter Filter DropIndexOnTable bool SupportFilter bool }
Index builder.
func (Index) WriteCreateIndex ¶
WriteCreateIndex to buffer
func (Index) WriteDropIndex ¶
WriteDropIndex to buffer
func (Index) WriteOptions ¶
WriteOptions sql to buffer.
type Insert ¶
type Insert struct { BufferFactory BufferFactory ReturningPrimaryValue bool InsertDefaultValues bool OnConflict OnConflict }
Insert builder.
func (Insert) Build ¶
func (i Insert) Build(table string, primaryField string, mutates map[string]rel.Mutate, onConflict rel.OnConflict) (string, []any)
Build sql query and its arguments.
func (Insert) WriteInsertInto ¶ added in v0.9.0
func (Insert) WriteReturning ¶ added in v0.9.0
type InsertAll ¶
type InsertAll struct { BufferFactory BufferFactory ReturningPrimaryValue bool OnConflict OnConflict }
InsertAll builder.
func (InsertAll) Build ¶
func (ia InsertAll) Build(table string, primaryField string, fields []string, bulkMutates []map[string]rel.Mutate, onConflict rel.OnConflict) (string, []any)
Build SQL string and its arguments.
func (InsertAll) WriteInsertInto ¶ added in v0.9.0
func (InsertAll) WriteReturning ¶ added in v0.9.0
type OnConflict ¶ added in v0.9.0
type OnConflict struct { Statement string IgnoreStatement string UpdateStatement string TableQualifier string SupportKey bool UseValues bool }
func (OnConflict) Write ¶ added in v0.9.0
func (oc OnConflict) Write(buffer *Buffer, fields []string, onConflict rel.OnConflict)
func (OnConflict) WriteIgnore ¶ added in v0.9.0
func (oc OnConflict) WriteIgnore(buffer *Buffer, fields []string)
func (OnConflict) WriteKeys ¶ added in v0.9.0
func (oc OnConflict) WriteKeys(buffer *Buffer, onConflict rel.OnConflict)
func (OnConflict) WriteMutates ¶ added in v0.9.0
func (oc OnConflict) WriteMutates(buffer *Buffer, mutates map[string]rel.Mutate, onConflict rel.OnConflict)
func (OnConflict) WriteReplace ¶ added in v0.9.0
func (oc OnConflict) WriteReplace(buffer *Buffer, fields []string)
type Query ¶
type Query struct { BufferFactory BufferFactory Filter Filter }
Query builder.
func (Query) WriteGroupBy ¶
WriteGroupBy SQL to buffer.
func (Query) WriteHaving ¶
func (q Query) WriteHaving(buffer *Buffer, table string, filter rel.FilterQuery)
WriteHaving SQL to buffer.
func (Query) WriteLimitOffset ¶ added in v0.13.1
WriteLimitOffset SQL to buffer.
func (Query) WriteOrderBy ¶
WriteOrderBy SQL to buffer.
func (Query) WriteQuery ¶
WriteQuery SQL to buffer.
func (Query) WriteSelect ¶
func (q Query) WriteSelect(buffer *Buffer, table string, selectQuery rel.SelectQuery)
WriteSelect SQL to buffer.
func (Query) WriteWhere ¶
func (q Query) WriteWhere(buffer *Buffer, table string, filter rel.FilterQuery)
WriteWhere SQL to buffer.
type QueryWriter ¶
type Quote ¶ added in v0.2.0
type Quote struct { IDPrefix string IDSuffix string IDSuffixEscapeChar string ValueQuote string ValueQuoteEscapeChar string }
Quote is default implementation of Quoter interface.
type Quoter ¶ added in v0.2.0
type Quoter interface { // ID quotes identifiers such as schema, table, or column names. // ID does not operate on multipart identifiers such as "public.Table", // it only operates on single identifiers such as "public" and "Table". ID(name string) string // Value quotes database values such as string or []byte types as strings // that are suitable and safe to embed in SQL text. The returned value // of a string will include all surrounding quotes. // // If a value type is not supported it must panic. Value(v any) string }
Quoter returns safe and valid SQL strings to use when building a SQL text.
type Table ¶
type Table struct { BufferFactory BufferFactory ColumnMapper ColumnMapper ColumnOptionsMapper ColumnOptionsMapper DropKeyMapper DropKeyMapper DefinitionFilter DefinitionFilter }
Table builder.
func (Table) WriteAlterTable ¶
WriteAlterTable query to buffer.
func (Table) WriteColumn ¶
WriteColumn definition to buffer.
func (Table) WriteCreateTable ¶
WriteCreateTable query to buffer.
func (Table) WriteDropTable ¶
WriteDropTable query to buffer.
func (Table) WriteOptions ¶
WriteOptions sql to buffer.