Documentation ¶
Index ¶
- Variables
- type Elasticsearch
- func (self *Elasticsearch) AggregateByField(agg filter.Aggregation, field string) error
- func (self *Elasticsearch) Finalize(flt *filter.Filter) error
- func (self *Elasticsearch) GetValues() []interface{}
- func (self *Elasticsearch) GroupByField(field string) error
- func (self *Elasticsearch) Initialize(collectionName string) error
- func (self *Elasticsearch) SetMinimumVersion(v float64)
- func (self *Elasticsearch) SetOption(key string, value interface{}) error
- func (self *Elasticsearch) WithCriterion(criterion filter.Criterion) error
- func (self *Elasticsearch) WithField(field string) error
- type MongoDB
- func (self *MongoDB) AggregateByField(agg filter.Aggregation, field string) error
- func (self *MongoDB) Finalize(f *filter.Filter) error
- func (self *MongoDB) GetValues() []interface{}
- func (self *MongoDB) GroupByField(field string) error
- func (self *MongoDB) Initialize(collectionName string) error
- func (self *MongoDB) SetOption(key string, value interface{}) error
- func (self *MongoDB) WithCriterion(criterion filter.Criterion) error
- func (self *MongoDB) WithField(field string) error
- type Sql
- func (self *Sql) AggregateByField(agg filter.Aggregation, field string) error
- func (self *Sql) ApplyNormalizer(fieldName string, in string) string
- func (self *Sql) ArrayTypeDecode(in []byte, out interface{}) error
- func (self *Sql) ArrayTypeEncode(in interface{}) ([]byte, error)
- func (self *Sql) Finalize(f *filter.Filter) error
- func (self *Sql) GetPlaceholder(fieldName string) string
- func (self *Sql) GetValues() []interface{}
- func (self *Sql) GroupByField(field string) error
- func (self *Sql) Initialize(collectionName string) error
- func (self *Sql) ObjectTypeDecode(in []byte, out interface{}) error
- func (self *Sql) ObjectTypeEncode(in interface{}) ([]byte, error)
- func (self *Sql) PrepareInputValue(f string, value interface{}) (interface{}, error)
- func (self *Sql) SetOption(_ string, _ interface{}) error
- func (self *Sql) SplitTypeLength(in string) (string, int, int)
- func (self *Sql) ToAggregatedFieldName(agg filter.Aggregation, field string) string
- func (self *Sql) ToFieldName(field string) string
- func (self *Sql) ToNativeType(in dal.Type, subtypes []dal.Type, length int) (string, error)
- func (self *Sql) ToNativeValue(t dal.Type, subtypes []dal.Type, in interface{}) string
- func (self *Sql) ToTableName(table string) string
- func (self *Sql) WithCriterion(criterion filter.Criterion) error
- func (self *Sql) WithField(field string) error
- type SqlArrayTypeDecodeFunc
- type SqlArrayTypeEncodeFunc
- type SqlObjectTypeDecodeFunc
- type SqlObjectTypeEncodeFunc
- type SqlStatementType
- type SqlTypeMapping
Constants ¶
This section is empty.
Variables ¶
View Source
var CassandraTypeMapping = SqlTypeMapping{
Name: `cassandra`,
StringType: `VARCHAR`,
IntegerType: `INT`,
FloatType: `FLOAT`,
BooleanType: `TINYINT`,
BooleanTypeLength: 1,
DateTimeType: `DATETIME`,
ObjectType: `MAP`,
ArrayType: `LIST`,
RawType: `BLOB`,
SubtypeFormat: `%s<%v>`,
MultiSubtypeFormat: `%s<%v,%v>`,
PlaceholderFormat: `TODO`,
PlaceholderArgument: `TODO`,
TableNameFormat: "%s",
FieldNameFormat: "%s",
NestedFieldSeparator: `.`,
NestedFieldJoiner: `.`,
}
View Source
var DefaultMinVersionCompat = float64(6)
Elasticsearch Generator
View Source
var DefaultSqlTypeMapping = GenericTypeMapping
View Source
var ElasticsearchExactMatchQueryType = `term`
View Source
var ElasticsearchFulltextDefaultConjunctionAnd = true
View Source
var GenericTypeMapping = SqlTypeMapping{
Name: `generic`,
StringType: `VARCHAR`,
StringTypeLength: 255,
IntegerType: `BIGINT`,
FloatType: `DECIMAL`,
FloatTypeLength: 10,
FloatTypePrecision: 8,
BooleanType: `BOOL`,
DateTimeType: `DATETIME`,
ObjectType: `BLOB`,
ArrayType: `BLOB`,
RawType: `BLOB`,
PlaceholderFormat: `?`,
PlaceholderArgument: ``,
TableNameFormat: "%s",
FieldNameFormat: "%s",
NestedFieldSeparator: `.`,
NestedFieldJoiner: `.`,
}
View Source
var MysqlTypeMapping = SqlTypeMapping{
Name: `mysql`,
StringType: `VARCHAR`,
StringTypeLength: 255,
IntegerType: `BIGINT`,
FloatType: `DECIMAL`,
FloatTypeLength: 10,
FloatTypePrecision: 8,
BooleanType: `BOOL`,
DateTimeType: `DATETIME`,
ObjectType: `MEDIUMBLOB`,
ArrayType: `MEDIUMBLOB`,
RawType: `MEDIUMBLOB`,
PlaceholderFormat: `?`,
PlaceholderArgument: ``,
TableNameFormat: "`%s`",
FieldNameFormat: "`%s`",
NestedFieldSeparator: `.`,
NestedFieldJoiner: `.`,
}
View Source
var NoTypeMapping = SqlTypeMapping{}
View Source
var PostgresJsonTypeMapping = SqlTypeMapping{
Name: `postgres-json`,
StringType: `TEXT`,
IntegerType: `BIGINT`,
FloatType: `NUMERIC`,
BooleanType: `BOOLEAN`,
DateTimeType: `TIMESTAMP`,
ObjectType: `VARCHAR`,
ArrayType: `VARCHAR`,
RawType: `BYTEA`,
PlaceholderFormat: `$%d`,
PlaceholderArgument: `index1`,
TableNameFormat: "%q",
FieldNameFormat: "%q",
NestedFieldSeparator: `.`,
NestedFieldJoiner: `.`,
}
View Source
var PostgresTypeMapping = SqlTypeMapping{
Name: `postgres`,
StringType: `TEXT`,
IntegerType: `BIGINT`,
FloatType: `NUMERIC`,
BooleanType: `BOOLEAN`,
DateTimeType: `TIMESTAMP`,
ObjectType: `VARCHAR`,
ArrayType: `VARCHAR`,
RawType: `BYTEA`,
PlaceholderFormat: `$%d`,
PlaceholderArgument: `index1`,
TableNameFormat: "%q",
FieldNameFormat: "%q",
NestedFieldSeparator: `.`,
NestedFieldJoiner: `.`,
}
View Source
var SqlJsonTypeDecoder = func(in []byte, out interface{}) error { return json.NewDecoder(bytes.NewReader(in)).Decode(out) }
View Source
var SqlJsonTypeEncoder = func(in interface{}) ([]byte, error) { var buf bytes.Buffer err := json.NewEncoder(&buf).Encode(in) return buf.Bytes(), err }
View Source
var SqlMaxPlaceholders = 16384
View Source
var SqliteTypeMapping = SqlTypeMapping{
Name: `sqlite`,
StringType: `TEXT`,
IntegerType: `INTEGER`,
FloatType: `REAL`,
BooleanType: `INTEGER`,
BooleanTypeLength: 1,
DateTimeType: `INTEGER`,
ObjectType: `BLOB`,
ArrayType: `BLOB`,
RawType: `BLOB`,
PlaceholderFormat: `?`,
PlaceholderArgument: ``,
TableNameFormat: "%q",
FieldNameFormat: "%q",
NestedFieldSeparator: `.`,
NestedFieldJoiner: `.`,
}
Functions ¶
This section is empty.
Types ¶
type Elasticsearch ¶
func NewElasticsearchGenerator ¶
func NewElasticsearchGenerator() *Elasticsearch
func (*Elasticsearch) AggregateByField ¶
func (self *Elasticsearch) AggregateByField(agg filter.Aggregation, field string) error
func (*Elasticsearch) GetValues ¶
func (self *Elasticsearch) GetValues() []interface{}
func (*Elasticsearch) GroupByField ¶
func (self *Elasticsearch) GroupByField(field string) error
func (*Elasticsearch) Initialize ¶
func (self *Elasticsearch) Initialize(collectionName string) error
func (*Elasticsearch) SetMinimumVersion ¶ added in v3.1.12
func (self *Elasticsearch) SetMinimumVersion(v float64)
func (*Elasticsearch) SetOption ¶
func (self *Elasticsearch) SetOption(key string, value interface{}) error
func (*Elasticsearch) WithCriterion ¶
func (self *Elasticsearch) WithCriterion(criterion filter.Criterion) error
func (*Elasticsearch) WithField ¶
func (self *Elasticsearch) WithField(field string) error
type MongoDB ¶
func NewMongoDBGenerator ¶
func NewMongoDBGenerator() *MongoDB
func (*MongoDB) AggregateByField ¶
func (self *MongoDB) AggregateByField(agg filter.Aggregation, field string) error
func (*MongoDB) GroupByField ¶
func (*MongoDB) Initialize ¶
func (*MongoDB) WithCriterion ¶
type Sql ¶
type Sql struct { filter.Generator FieldWrappers map[string]string // map of field name-format strings to wrap specific fields in after FieldNameFormat is applied NormalizeFields []string // a list of field names that should have the NormalizerFormat applied to them and their corresponding values NormalizerFormat string // format string used to wrap fields and value clauses for the purpose of doing fuzzy searches UseInStatement bool // whether multiple values in a criterion should be tested using an IN() statement Distinct bool // whether a DISTINCT clause should be used in SELECT statements Count bool // whether this query is being used to count rows, which means that SELECT fields are discarded in favor of COUNT(1) TypeMapping SqlTypeMapping // provides mapping information between DAL types and native SQL types Type SqlStatementType // what type of SQL statement is being generated InputData map[string]interface{} // key-value data for statement types that require input data (e.g.: inserts, updates) // contains filtered or unexported fields }
func NewSqlGenerator ¶
func NewSqlGenerator() *Sql
func (*Sql) AggregateByField ¶
func (self *Sql) AggregateByField(agg filter.Aggregation, field string) error
func (*Sql) ArrayTypeDecode ¶ added in v3.1.0
func (*Sql) ArrayTypeEncode ¶ added in v3.1.0
func (*Sql) Finalize ¶
Takes all the information collected so far and generates a SQL statement from it
func (*Sql) GetPlaceholder ¶
func (*Sql) GroupByField ¶
func (*Sql) Initialize ¶
func (*Sql) ObjectTypeDecode ¶
func (*Sql) ObjectTypeEncode ¶
func (*Sql) PrepareInputValue ¶
func (*Sql) ToAggregatedFieldName ¶
func (self *Sql) ToAggregatedFieldName(agg filter.Aggregation, field string) string
func (*Sql) ToFieldName ¶
func (*Sql) ToNativeType ¶
func (*Sql) ToNativeValue ¶
func (*Sql) ToTableName ¶
type SqlArrayTypeDecodeFunc ¶ added in v3.1.0
type SqlArrayTypeEncodeFunc ¶ added in v3.1.0
type SqlObjectTypeDecodeFunc ¶
type SqlObjectTypeEncodeFunc ¶
type SqlStatementType ¶
type SqlStatementType int
const ( SqlSelectStatement SqlStatementType = iota SqlInsertStatement SqlUpdateStatement SqlDeleteStatement )
type SqlTypeMapping ¶
type SqlTypeMapping struct { Name string StringType string StringTypeLength int IntegerType string FloatType string FloatTypeLength int FloatTypePrecision int BooleanType string BooleanTypeLength int DateTimeType string ObjectType string ArrayType string RawType string SubtypeFormat string MultiSubtypeFormat string PlaceholderFormat string // if using placeholders, the format string used to insert them PlaceholderArgument string // if specified, either "index", "index1" or "field" TableNameFormat string // format string used to wrap table names FieldNameFormat string // format string used to wrap field names NestedFieldNameFormat string // map of field name-format strings to wrap fields addressing nested map keys. supercedes FieldNameFormat NestedFieldSeparator string // the string used to denote nesting in a nested field name NestedFieldJoiner string // the string used to re-join all but the first value in a nested field when interpolating into NestedFieldNameFormat ObjectTypeEncodeFunc SqlObjectTypeEncodeFunc // function used for encoding objects to a native representation ObjectTypeDecodeFunc SqlObjectTypeDecodeFunc // function used for decoding objects from native into a destination map ArrayTypeEncodeFunc SqlArrayTypeEncodeFunc // function used for encoding arrays to a native representation ArrayTypeDecodeFunc SqlArrayTypeDecodeFunc // function used for decoding arrays from native into a destination map }
func GetSqlTypeMapping ¶
func GetSqlTypeMapping(name string) (SqlTypeMapping, error)
func (SqlTypeMapping) String ¶ added in v3.1.0
func (self SqlTypeMapping) String() string
Click to show internal directories.
Click to hide internal directories.