Closed thomaspeugeot closed 11 months ago
There is a gin problem with JSON serialize when Bs in PointerEncoding is the same as in Models.A
type AAPI struct {
gorm.Model
// why models.A It should be AWOP
models.A
// encoding of pointers
APointersEncoding
}
// APointersEncoding encodes pointers to Struct and
// reverse pointers of slice of poitners to Struct
type APointersEncoding struct {
// insertion for pointer fields encoding declaration
B2s StringSlice `gorm:"type:TEXT"`
}
Solution is to have AAPI uses AWOP.
Steps
Rationale
With package hierarchy, navigating from the target to the source in a relation:
What is lost is
Opportunities
Associations to interface (pointer or slice of pointers) polymorphic association
could be rewritten to
could the pointer be encoded in "named struct code" + "instance ID" ?
Exploration
How does gorm encode Many association ? Well, not good
the example given below is not good. It does not encode the slice of
CreditCard
as a slice of pointers but as a slice...gloopHow does gorm encode slice of integers, of struct with two integers ?
space efficient
easier to debug
However, the space efficiency makes senses only when integers are above 1 billions (see https://github.com/thomaspeugeot/test_gorm)
Impact analysis on the back (ORM)
There is the
PointerEncoding
part where it is defined. For Astruct.AnanrrayofbOwner
Destination
Impact analysis on the front
Impact analysis on frequently used stacks