ghetzel / pivot

An extensible database abstraction service, written in Golang.
GNU Lesser General Public License v2.1
66 stars 5 forks source link

Embedded record expansion returns inconsistent cached results #12

Open ghetzel opened 5 years ago

ghetzel commented 5 years ago

In the case where a schema definition contains multiple embedded record expansions pointing to the same table, but where each expansion exposes different fields to return, it is undefined which field set will be associated with each expanded field.

e.g.:

[{
    "name": "mycollection",
    "embed": [{
        "key":        "expand1",
        "collection": "other",
        "fields": [
            "name",
            "enabled"
        ]
    }, {
        "key":        "expand2",
        "collection": "other",
        "fields": [
            "name",
            "email",
            "password"
        ]
    },

    ...
}]

In the above case, it is undefined whether expand1 and expand2 will contain a record with the fields name and enabled; or fields name, email, and password. The values are seen to switch intermittently.

This is almost certainly a cache optimization gone wrong (e.g.: keying on just identity instead of indentity+fields).