func (builder *MySQLGoDataProvider) ExposeManyToOne(a, b *MySQLGoDataEntity, acol, aprop, bprop string) {
	prop := GoDataNavigationProperty{Name: aprop, Type: builder.Namespace + "." + b.EntityType.Name, Partner: bprop}
	a.EntityType.NavigationProperties = append(a.EntityType.NavigationProperties, &prop)
	prop2 := GoDataNavigationProperty{Name: bprop, Type: "Collection(" + builder.Namespace + "." + a.EntityType.Name + ")", Partner: aprop}
	b.EntityType.NavigationProperties = append(b.EntityType.NavigationProperties, &prop2)
	constrainedProp := b.EntityType.Key.PropertyRef.Name
	a.ExposeProperty(acol, constrainedProp, b.KeyType)
	constraint := GoDataReferentialConstraint{Property: constrainedProp, ReferencedProperty: constrainedProp}
	prop2.ReferentialConstraints = append(prop2.ReferentialConstraints, &constraint)
	a.PropColMap[aprop] = acol
	a.ColPropMap[acol] = aprop
}
Adds the necessary NavigationProperty tags to an entity to expose a many-to-one
relationship from a (Many) -> b (One). A column name must be provided for entity a
which will map to the key in entity b. A reverse property will be added to
entity b to map back to entity a, and does not need an explicit column.
package mysql
import (
	"fmt"
	. "godata"
)
const (
	XMLNamespace string = "http://docs.oasis-open.org/odata/ns/edmx"
	ODataVersion string = "4.0"
)
var MySQLPrepareMap = map[string]string{
	"contains":   "%?%",
	"endswith":   "%?",
	"startswith": "?%",
}
var MySQLNodeMap = map[string]string{
	"eq":  "(%s = %s)",
	"nq":  "(%s != %s)",
	"gt":  "(%s > %s)",
	"ge":  "(%s >= %s)",
	"lt":  "(%s < %s)",
	"le":  "(%s <= %s)",
	"and": "(%s AND %s)",
	"or":  "(%s OR %s)",
	"not": "(NOT %s)",
	"contains":   "(%s LIKE %s)",
	"endswith":   "(%s LIKE %s)",
	"startswith": "(%s LIKE %s)",
	"length":     "LENGTH(%s)",
	"indexof":    "LOCATE(%s)",
	"tolower":          "LOWER(%s)",
	"toupper":          "UPPER(%s)",
	"trim":             "TRIM(%s)",
	"concat":           "CONCAT(%s,%s)",
	"year":             "YEAR(%s)",
	"month":            "MONTH(%s)",
	"day":              "DAY(%s)",
	"hour":             "HOUR(%s)",
	"minute":           "MINUTE(%s)",
	"second":           "SECOND(%s)",
	"fractionalsecond": "MICROSECOND(%s)",
	"date":             "DATE(%s)",
	"time":             "TIME(%s)",
	"now": "NOW()",
	"round":   "ROUND(%s)",
	"floor":   "FLOOR(%s)",
	"ceiling": "CEIL(%s)",
	"null": "NULL",
}
type MySQLConnectionParams struct {
	Database string
	Hostname string
	Port     string
	Username string
	Password string
}
type MySQLGoDataProvider struct {
	ConnectionParams *MySQLConnectionParams
	Namespace        string
	Entities         map[string]*MySQLGoDataEntity
	EntitySets       map[string]*MySQLGoDataEntitySet
	Actions          map[string]*GoDataAction
	Functions        map[string]*GoDataFunction
	Metadata         *GoDataMetadata
}
type MySQLGoDataEntity struct {
	TableName  string
	KeyType    string
	PropColMap map[string]string
	ColPropMap map[string]string
	EntityType *GoDataEntityType
}
type MySQLGoDataEntitySet struct {
	Entity    *MySQLGoDataEntity
	EntitySet *GoDataEntitySet
}
func BuildMySQLProvider(cxnParams *MySQLConnectionParams, namespace string) *MySQLGoDataProvider {
	return &MySQLGoDataProvider{
		ConnectionParams: cxnParams,
		Entities:         make(map[string]*MySQLGoDataEntity),
		EntitySets:       make(map[string]*MySQLGoDataEntitySet),
	}
}
func (p *MySQLGoDataProvider) BuildQuery(r *GoDataRequest) (string, error) {
	setName := r.FirstSegment.Name
	entitySet := p.EntitySets[setName]
	tableName := entitySet.Entity.TableName
	pKeyValue := r.FirstSegment.Identifier
	query := []byte{}
	params := []string{}
	selectClause, selectParams, selectErr := p.BuildSelectClause(r)
	if selectErr != nil {
		return nil, selectErr
	}
	query = append(query, selectClause)
	params = append(params, selectParams)
	fromClause, fromParams, fromErr := p.BuildFromClause(r)
	if fromErr != nil {
		return nil, fromErr
	}
	query = append(query, selectClause)
	params = append(params, selectParams)
}
func (p *MySQLGoDataProvider) BuildSelectClause(r *GoDataRequest) ([]byte, []string, error) {
}
func (p *MySQLGoDataProvider) BuildFromClause(r *GoDataRequest) ([]byte, []string, error) {
}
func (p *MySQLGoDataProvider) BuildWhereClause(r *GoDataRequest) ([]byte, []string, error) {
	recursiveBuildWhere := func(n *ParseNode) ([]byte, []string, error) {
		if n.Token.Type == FilterTokenLiteral {
			return []byte("?"), []byte(n.Token.Value), nil
		}
		if v, ok := MySQLNodeMap[n.Token.Value]; ok {
			params := string
			children := []byte{}
			for _, child := range n.Children {
				q, o, err := recursiveBuildWhere(child)
				if err != nil {
					return nil, nil, err
				}
				children := append(children, q)
				params := append(params, o)
			}
			result := fmt.Sprintf(v, children...)
			return []byte(result), params, nil
		} else {
			return nil, nil, NotImplementedError(n.Token.Value + " is not implemented.")
		}
	}
}
func (p *MySQLGoDataProvider) Response(r *GoDataRequest) *GoDataResponse {
	return nil
}
func (builder *MySQLGoDataProvider) BuildMetadata() *GoDataMetadata {
	entitySets := make([]*GoDataEntitySet, len(builder.EntitySets))
	for _, v := range builder.EntitySets {
		entitySets = append(entitySets, v.EntitySet)
	}
	entityTypes := make([]*GoDataEntityType, len(builder.Entities))
	for _, v := range builder.Entities {
		entityTypes = append(entityTypes, v.EntityType)
	}
	container := GoDataEntityContainer{
		Name:       builder.ConnectionParams.Database,
		EntitySets: entitySets,
	}
	schema := GoDataSchema{
		Namespace:        builder.Namespace,
		EntityTypes:      entityTypes,
		EntityContainers: []*GoDataEntityContainer{&container},
	}
	services := GoDataServices{
		Schemas: []*GoDataSchema{&schema},
	}
	root := GoDataMetadata{
		XMLNamespace: XMLNamespace,
		Version:      ODataVersion,
		DataServices: &services,
	}
	return &root
}
func (builder *MySQLGoDataProvider) ExposeEntity(tblname, entityname string) *MySQLGoDataEntity {
	entitytype := GoDataEntityType{Name: entityname}
	myentity := &MySQLGoDataEntity{tblname, "", map[string]string{}, map[string]string{}, &entitytype}
	builder.Entities[entityname] = myentity
	return myentity
}
func (builder *MySQLGoDataProvider) ExposeEntitySet(entity *MySQLGoDataEntity, setname string) *MySQLGoDataEntitySet {
	entityset := &GoDataEntitySet{Name: setname, EntityType: builder.Namespace + "." + entity.EntityType.Name}
	myset := &MySQLGoDataEntitySet{entity, entityset}
	builder.EntitySets[setname] = myset
	return myset
}
func (builder *MySQLGoDataProvider) ExposeOneToOne(a, b *MySQLGoDataEntity, acol, bcol, aprop, bprop string) {
	prop := GoDataNavigationProperty{Name: aprop, Type: builder.Namespace + "." + b.EntityType.Name, Partner: bprop}
	a.EntityType.NavigationProperties = append(a.EntityType.NavigationProperties, &prop)
	prop2 := GoDataNavigationProperty{Name: bprop, Type: builder.Namespace + "." + a.EntityType.Name, Partner: aprop}
	b.EntityType.NavigationProperties = append(b.EntityType.NavigationProperties, &prop2)
	a.PropColMap[aprop] = acol
	a.ColPropMap[acol] = aprop
	b.PropColMap[bprop] = bcol
	b.ColPropMap[bcol] = bprop
}