func Compile(where criteria.Expression) (whereClause string, parameters []interface{}, joins []*TableJoin, err []error) {
	compiler := newExpressionCompiler()

	criteria.IteratePostOrder(where, bubbleUpJSONContext(&compiler))

	compiled := where.Accept(&compiler)

	c, ok := compiled.(string)
	if !ok {
		c = ""
	}

	// Make sure we don't return all possible joins but only the once that were
	// activated. Returning them as a slice preserves the correct order of
	// joins.
	joins, e := compiler.joins.GetOrderdActivatedJoins()
	if e != nil {
		compiler.err = append(compiler.err, e)
	}

	for _, j := range joins {
		if j.Where == "" {
			continue
		}
		if c != "" {
			c += " AND "
		}
		c += j.Where
	}

	return c, compiler.parameters, joins, compiler.err
}
// Compile takes an expression and compiles it to a where clause for use with
// gorm.DB.Where(). Returns the number of expected parameters for the query and a
// slice of errors if something goes wrong.
Compile takes an expression and compiles it to a where clause for use with
gorm.DB.Where(). Returns the number of expected parameters for the query and a
slice of errors if something goes wrong.
// Compile takes an expression and compiles it to a where clause for use with // gorm . DB . Where () . Returns the number of expected parameters for the query and a // slice of errors if something goes wrong .
func Compile(where criteria.Expression) (whereClause string, parameters []interface{}, joins []*TableJoin, err []error) {
	compiler := newExpressionCompiler()
	criteria.IteratePostOrder(where, bubbleUpJSONContext(&compiler))
	compiled := where.Accept(&compiler)
	c, ok := compiled.(string)
	if !ok {
		c = ""
	}
	joins, e := compiler.joins.GetOrderdActivatedJoins()
	if e != nil {
		compiler.err = append(compiler.err, e)
	}
	for _, j := range joins {
		if j.Where == "" {
			continue
		}
		if c != "" {
			c += " AND "
		}
		c += j.Where
	}
	return c, compiler.parameters, joins, compiler.err
}
func Compile ( where criteria . Expression ) ( whereClause string , parameters [ ] interface { } , joins [ ] * TableJoin , err [ ] error ) { compiler := newExpressionCompiler ( ) criteria . IteratePostOrder ( where , bubbleUpJSONContext ( & compiler ) ) compiled := where . Accept ( & compiler ) c , ok := compiled . ( string ) if ! ok { c = " " } joins , e := compiler . joins . GetOrderdActivatedJoins ( ) if e != nil { compiler . err = append ( compiler . err , e ) } for _ , j := range joins { if j . Where == " " { continue } if c != " " { c += " " } c += j . Where } return c , compiler . parameters , joins , compiler . err }
Compile takes an expression and compiles it to a where clause for use with
gorm.DB.Where().
Compile takes an expression and compiles it to a where clause for use with gorm . DB . Where () .
// Make sure we don't return all possible joins but only the once that were // activated. Returning them as a slice preserves the correct order of // joins.