Beispiel #1
0
func (v Visitor) writeModel(sqlbuf, modelbuf *bytes2.Buffer) error {
	var table *Table

	err := v.modelTable(modelbuf, &table)
	if err == nil {
		sqlbuf.WriteString(table.Name)
	}

	return err
}
Beispiel #2
0
func (v Visitor) writeField(table *Table, withModel bool, sqlbuf, modelbuf, fieldbuf *bytes2.Buffer) error {
	field := fieldbuf.String()
	col := table.Fields.Get(field)
	if col == nil {
		return errors.Newf("field %s of model %s not found", field, modelbuf.String())
	}

	if withModel {
		sqlbuf.WriteString(table.Name)
		sqlbuf.WriteByte('.')
	}
	sqlbuf.WriteString(col.(string))

	return nil
}