Skip to content

record.Get().Bytes() corrupts bytea data on retrieval from PostgreSQL #4677

@RidaLiu

Description

@RidaLiu

Go version

go1.25.0 darwin/arm64

GoFrame version

v2.9.4

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

When storing a binary []byte slice (such as a gob stream) in a PostgreSQL bytea column and
retrieving it using the gogf/gf ORM, the record.Get("column").Bytes() method does not
return a byte-for-byte identical slice. It appears to append extra, unexpected data to the
end of the byte slice, causing deserialization errors for binary formats like gob.
Environment:

  • Database: PostgreSQL
  • Column Type: bytea

What did you see happen?

Steps to Reproduce:

  1. Save a []byte slice to a bytea column using dao.Data(do.MyStruct{Value:
    myBytes}).Save().
  2. Retrieve the row using dao.Where(...).One().
  3. Get the value using retrievedBytes := record.Get("value").Bytes().
  4. Compare the len() and sha256.Sum256() of myBytes and retrievedBytes.

What did you expect to see?

Expected Result:
The length and SHA256 hash of the original and retrieved byte slices should be identical.
Actual Result:
The retrieved byte slice is longer than the original and has a different SHA256 hash,
indicating data corruption.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIt is confirmed a bug, but don't worry, we'll handle it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions