func (c *expressionCompiler) Field(f *criteria.FieldExpression) interface{} {
	if strings.Contains(f.FieldName, `"`) {
		c.err = append(c.err, errs.Errorf("field name must not contain double quotes: %s", f.FieldName))
		return nil
	}
	if strings.Contains(f.FieldName, `'`) {
		c.err = append(c.err, errs.Errorf("field name must not contain single quotes: %s", f.FieldName))
		return nil
	}

	mappedFieldName, isJSONField := c.getFieldName(f.FieldName)

	// Check if this field is referencing joinable data
	for _, j := range c.joins {
		if j.HandlesFieldName(mappedFieldName) {
			j.Active = true
			col, err := j.TranslateFieldName(mappedFieldName)
			if err != nil {
				c.err = append(c.err, errs.Wrapf(err, `failed to translate field "%s"`, mappedFieldName))
			}
			return col // e.g. "iter.name"
		}
	}

	if !isJSONField {
		return mappedFieldName
	}
	if strings.Contains(mappedFieldName, "'") {
		// beware of injection, it's a reasonable restriction for field names,
		// make sure it's not allowed when creating wi types
		c.err = append(c.err, errs.Errorf("single quote not allowed in field name: %s", mappedFieldName))
		return nil
	}

	// default to plain json field (e.g. for ID comparisons)
	return Column(WorkItemStorage{}.TableName(), "fields") + ` @> '{"` + mappedFieldName + `"`
}
// visitor implementation
// the convention is to return nil when the expression cannot be compiled and to append an error to the err field
visitor implementation
the convention is to return nil when the expression cannot be compiled and to append an error to the err field
// visitor implementation // the convention is to return nil when the expression cannot be compiled and to append an error to the err field
func (c *expressionCompiler) Field(f *criteria.FieldExpression) interface{} {
	if strings.Contains(f.FieldName, `"`) {
		c.err = append(c.err, errs.Errorf("field name must not contain double quotes: %s", f.FieldName))
		return nil
	}
	if strings.Contains(f.FieldName, `'`) {
		c.err = append(c.err, errs.Errorf("field name must not contain single quotes: %s", f.FieldName))
		return nil
	}
	mappedFieldName, isJSONField := c.getFieldName(f.FieldName)
	for _, j := range c.joins {
		if j.HandlesFieldName(mappedFieldName) {
			j.Active = true
			col, err := j.TranslateFieldName(mappedFieldName)
			if err != nil {
				c.err = append(c.err, errs.Wrapf(err, `failed to translate field "%s"`, mappedFieldName))
			}
			return col 
		}
	}
	if !isJSONField {
		return mappedFieldName
	}
	if strings.Contains(mappedFieldName, "'") {
		c.err = append(c.err, errs.Errorf("single quote not allowed in field name: %s", mappedFieldName))
		return nil
	}
	return Column(WorkItemStorage{}.TableName(), "fields") + ` @> '{"` + mappedFieldName + `"`
}
func ( c * expressionCompiler ) Field ( f * criteria . FieldExpression ) interface { } { if strings . Contains ( f . FieldName , `"` ) { c . err = append ( c . err , errs . Errorf ( " " , f . FieldName ) ) return nil } if strings . Contains ( f . FieldName , `'` ) { c . err = append ( c . err , errs . Errorf ( " " , f . FieldName ) ) return nil } mappedFieldName , isJSONField := c . getFieldName ( f . FieldName ) for _ , j := range c . joins { if j . HandlesFieldName ( mappedFieldName ) { j . Active = true col , err := j . TranslateFieldName ( mappedFieldName ) if err != nil { c . err = append ( c . err , errs . Wrapf ( err , `failed to translate field "%s"` , mappedFieldName ) ) } return col } } if ! isJSONField { return mappedFieldName } if strings . Contains ( mappedFieldName , " " ) { c . err = append ( c . err , errs . Errorf ( " " , mappedFieldName ) ) return nil } return Column ( WorkItemStorage { } . TableName ( ) , " " ) + ` @> '{"` + mappedFieldName + `"` }
visitor implementation
the convention is to return nil when the expression cannot be compiled and to append an error to the err field
visitor implementation the convention is to return nil when the expression cannot be compiled and to append an error to the err field
// Check if this field is referencing joinable data // e.g. "iter.name" // beware of injection, it's a reasonable restriction for field names, // make sure it's not allowed when creating wi types // default to plain json field (e.g. for ID comparisons)