Documentation
¶
Index ¶
- Constants
- func WithDialect(dialect string) func(*Adapter)
- func WithDialectMSSQL() func(*Adapter)
- func WithDialectMariaDB() func(*Adapter)
- func WithDialectPostgres() func(*Adapter)
- func WithDialectSQL92() func(*Adapter)
- func WithDialectSQL92NoDelimiter() func(*Adapter)
- func WithDialectSQLite() func(*Adapter)
- func WithTableName(tableName string) func(*Adapter)
- type Adapter
- type Field
- type FieldMapping
- type MappingBuilder
- func (b *MappingBuilder) AddDateMapping(column, selector string) *MappingBuilder
- func (b *MappingBuilder) AddFloatMapping(column, selector string) *MappingBuilder
- func (b *MappingBuilder) AddIntMapping(column, selector string) *MappingBuilder
- func (b *MappingBuilder) AddStringMapping(column, selector string) *MappingBuilder
- func (b *MappingBuilder) Build() FieldMapping
- type OrderByClause
- type WherePredicate
Constants ¶
const ( DialectMariaDB = "maria" DialectMySQL = "mysql" DialectMSSL = "mssql" DialectSQLite = "sqlite3" DialectPostgres = "postgres" )
Dialect constants
Variables ¶
This section is empty.
Functions ¶
func WithDialect ¶
WithDialect configures which dialect to be used
func WithDialectMSSQL ¶
func WithDialectMSSQL() func(*Adapter)
WithDialectMSSQL configures MSSQL delimiters and params
func WithDialectMariaDB ¶
func WithDialectMariaDB() func(*Adapter)
WithDialectMariaDB configures MariaDB / MySql delimiters and params
func WithDialectPostgres ¶
func WithDialectPostgres() func(*Adapter)
WithDialectPostgres configures Postgres delimiters and params
func WithDialectSQL92 ¶
func WithDialectSQL92() func(*Adapter)
WithDialectSQL92 means column delimiter is " and parameters are ?
func WithDialectSQL92NoDelimiter ¶
func WithDialectSQL92NoDelimiter() func(*Adapter)
WithDialectSQL92NoDelimiter means no column delimiter is used and parameters are ?
func WithDialectSQLite ¶
func WithDialectSQLite() func(*Adapter)
WithDialectSQLite configures SQLite delimiters and params
func WithTableName ¶ added in v0.0.4
WithTableName creates an adapter that prefixes all columns with the given table name if a struct tag defines a table prefix it will take precedence over the supplied adapter table name
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter adapter is a fiql2sql adapter one adapter per table is needed unless all tables carry the same columns - but i would not recommend sharing adapters for multiple tables
func NewAdapter ¶
func NewAdapter(mapping FieldMapping, options ...func(*Adapter)) *Adapter
NewAdapter returns a new fiql adapter for the given field mapping use the MappingBuilder to create field mapping
func NewAdapterFor ¶
NewAdapterFor creates a new adapter from struct tags of the typeDef argument
func (*Adapter) OrderBy ¶
func (a *Adapter) OrderBy(query string) (*OrderByClause, error)
OrderBy generates a order by clause from a given query this is no fiql but rather the format ([+|-|])ALIAS[;([+|-|])ALIAS]*
type MappingBuilder ¶
type MappingBuilder struct {
// contains filtered or unexported fields
}
MappingBuilder helps build FieldMappings manually if no struct tags are used
func NewMappingBuilder ¶
func NewMappingBuilder() *MappingBuilder
NewMappingBuilder returns a new instance of a MappingBuilder
func (*MappingBuilder) AddDateMapping ¶
func (b *MappingBuilder) AddDateMapping(column, selector string) *MappingBuilder
AddDateMapping adds a column to fiql selector mapping for a date(time) column
func (*MappingBuilder) AddFloatMapping ¶
func (b *MappingBuilder) AddFloatMapping(column, selector string) *MappingBuilder
AddFloatMapping adds a column to fiql selector mapping for a decimal column
func (*MappingBuilder) AddIntMapping ¶
func (b *MappingBuilder) AddIntMapping(column, selector string) *MappingBuilder
AddIntMapping adds a column to fiql selector mapping for a numeric column
func (*MappingBuilder) AddStringMapping ¶
func (b *MappingBuilder) AddStringMapping(column, selector string) *MappingBuilder
AddStringMapping adds a column to fiql selector mapping for a string column
func (*MappingBuilder) Build ¶
func (b *MappingBuilder) Build() FieldMapping
Build returns the generated
type OrderByClause ¶
type OrderByClause struct {
// contains filtered or unexported fields
}
OrderByClause represents a order by clause without the order by keyword
func (*OrderByClause) Query ¶ added in v0.0.5
func (o *OrderByClause) Query() (string, []any)
Query satisfies querier interface from ent https://pkg.go.dev/entgo.io/ent@v0.12.4/dialect/sql#Querier
func (*OrderByClause) Sql ¶
func (o *OrderByClause) Sql() string
Sql returns the underlying sql string
func (*OrderByClause) String ¶
func (o *OrderByClause) String() string
String simply returns the query string
func (*OrderByClause) ToSql ¶
func (o *OrderByClause) ToSql() (string, []interface{}, error)
ToSql returns the query string and the parameters satisfies sqlizer https://pkg.go.dev/github.com/masterminds/squirrel#Sqlizer
type WherePredicate ¶
type WherePredicate struct {
// contains filtered or unexported fields
}
WherePredicate holds the content of a where predicate it will always be wrapped in outter most braces to avoid issues with OR chaining leading to unwated results it does not contain the WHERE keyword
func (*WherePredicate) Parameters ¶
func (w *WherePredicate) Parameters() []interface{}
Parameters return the underlying parameters
func (*WherePredicate) Query ¶
func (w *WherePredicate) Query() (string, []any)
Query satisfies querier interface from ent https://pkg.go.dev/entgo.io/ent@v0.12.4/dialect/sql#Querier
func (*WherePredicate) Sql ¶
func (w *WherePredicate) Sql() string
Sql returns the underlying sql string
func (*WherePredicate) String ¶
func (w *WherePredicate) String() string
String simply returns the query string and paremeters
func (*WherePredicate) ToSql ¶
func (w *WherePredicate) ToSql() (string, []interface{}, error)
ToSql returns the query string and the parameters satisfies sqlizer https://pkg.go.dev/github.com/masterminds/squirrel#Sqlizer