func (v Visitor) modelTable(modelbuf *bytes2.Buffer, table **Table) error { model := modelbuf.String() *table = v.Models[model] if *table == nil { return errors.Newf("model %s isn't registered", model) } return nil }
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 }
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 }
func writeReset(w func([]byte) error, b *bytes2.Buffer) error { err := w(b.Bytes()) b.Reset() return err }