(oid uint32, field any)
| 472 | } |
| 473 | |
| 474 | func (b *CompositeBinaryBuilder) AppendValue(oid uint32, field any) { |
| 475 | if b.err != nil { |
| 476 | return |
| 477 | } |
| 478 | |
| 479 | isNil, callNilDriverValuer := isNilDriverValuer(field) |
| 480 | if isNil && !callNilDriverValuer { |
| 481 | b.buf = pgio.AppendUint32(b.buf, oid) |
| 482 | b.buf = pgio.AppendInt32(b.buf, -1) |
| 483 | b.fieldCount++ |
| 484 | return |
| 485 | } |
| 486 | |
| 487 | var plan EncodePlan |
| 488 | if isNil { |
| 489 | plan = &encodePlanDriverValuer{m: b.m, oid: oid, formatCode: BinaryFormatCode} |
| 490 | } else { |
| 491 | plan = b.m.PlanEncode(oid, BinaryFormatCode, field) |
| 492 | if plan == nil { |
| 493 | b.err = fmt.Errorf("unable to encode %v into OID %d in binary format", field, oid) |
| 494 | return |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | b.buf = pgio.AppendUint32(b.buf, oid) |
| 499 | lengthPos := len(b.buf) |
| 500 | b.buf = pgio.AppendInt32(b.buf, -1) |
| 501 | fieldBuf, err := plan.Encode(field, b.buf) |
| 502 | if err != nil { |
| 503 | b.err = err |
| 504 | return |
| 505 | } |
| 506 | if fieldBuf != nil { |
| 507 | binary.BigEndian.PutUint32(fieldBuf[lengthPos:], uint32(len(fieldBuf)-len(b.buf))) |
| 508 | b.buf = fieldBuf |
| 509 | } |
| 510 | |
| 511 | b.fieldCount++ |
| 512 | } |
| 513 | |
| 514 | func (b *CompositeBinaryBuilder) Finish() ([]byte, error) { |
| 515 | if b.err != nil { |
no test coverage detected