mennanov / fmutils

Golang protobuf FieldMask missing utils
MIT License
97 stars 10 forks source link

Overwrite function does not support repeated Message fields #9

Closed geoffwatson closed 4 months ago

geoffwatson commented 4 months ago

Added to the testOverwrite function will panic.

{
            name:  "overwrite repeated message fields",
            paths: []string{"gallery.path"},
            src: &testproto.Profile{
                User: &testproto.User{
                    UserId: 567,
                    Name:   "different-name",
                },
                Photo: &testproto.Photo{
                    Path: "photo-path",
                },
                LoginTimestamps: []int64{1, 2, 3},
                Attributes: map[string]*testproto.Attribute{
                    "src": {},
                },
                Gallery: []*testproto.Photo{
                    {
                        PhotoId: 123,
                        Path:    "test-path-1",
                        Dimensions: &testproto.Dimensions{
                            Width:  345,
                            Height: 456,
                        },
                    },
                    {
                        PhotoId: 234,
                        Path:    "test-path-2",
                        Dimensions: &testproto.Dimensions{
                            Width:  3456,
                            Height: 4567,
                        },
                    },
                    {
                        PhotoId: 345,
                        Path:    "test-path-3",
                        Dimensions: &testproto.Dimensions{
                            Width:  34567,
                            Height: 45678,
                        },
                    },
                },
            },
            dest: &testproto.Profile{
                User: &testproto.User{
                    Name: "name",
                },
                Gallery: []*testproto.Photo{
                    {
                        PhotoId: 123,
                        Path:    "test-path-7",
                        Dimensions: &testproto.Dimensions{
                            Width:  345,
                            Height: 456,
                        },
                    },
                    {
                        PhotoId: 234,
                        Path:    "test-path-6",
                        Dimensions: &testproto.Dimensions{
                            Width:  3456,
                            Height: 4567,
                        },
                    },
                    {
                        PhotoId: 345,
                        Path:    "test-path-5",
                        Dimensions: &testproto.Dimensions{
                            Width:  34567,
                            Height: 45678,
                        },
                    },
                    {
                        PhotoId: 345,
                        Path:    "test-path-4",
                        Dimensions: &testproto.Dimensions{
                            Width:  34567,
                            Height: 45678,
                        },
                    },
                },
            },
            want: &testproto.Profile{
                User: &testproto.User{
                    Name: "name",
                },
                Gallery: []*testproto.Photo{
                    {
                        PhotoId: 123,
                        Path:    "test-path-1",
                        Dimensions: &testproto.Dimensions{
                            Width:  345,
                            Height: 456,
                        },
                    },
                    {
                        PhotoId: 234,
                        Path:    "test-path-2",
                        Dimensions: &testproto.Dimensions{
                            Width:  3456,
                            Height: 4567,
                        },
                    },
                    {
                        PhotoId: 345,
                        Path:    "test-path-3",
                        Dimensions: &testproto.Dimensions{
                            Width:  34567,
                            Height: 45678,
                        },
                    },
                },
            },
        },
geoffwatson commented 4 months ago

I have a fix for this, but do not have permissions to push it.

mennanov commented 4 months ago

@geoffwatson could you please create a pull request with a fix?

geoffwatson commented 4 months ago
ERROR: Permission to mennanov/fmutils.git denied to geoffwatson.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
mennanov commented 4 months ago

Hm.. try forking the repository first and then open a pull request: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo

geoffwatson commented 4 months ago

Sorry for the delay. https://github.com/mennanov/fmutils/pull/10