Code Monkey home page Code Monkey logo

Comments (6)

mennanov avatar mennanov commented on June 16, 2024 1

I'll take a look within the next few days

from fieldmask-utils.

mennanov avatar mennanov commented on June 16, 2024 1

A PR is welcomed!

from fieldmask-utils.

marcoshuck avatar marcoshuck commented on June 16, 2024

@mennanov any chances you can take a look at this?

from fieldmask-utils.

mennanov avatar mennanov commented on June 16, 2024

I wrote a similar test that passes:

func TestTitleBug(t *testing.T) {
	mask := &fieldmaskpb.FieldMask{Paths: []string{"title"}}
	mask.Normalize()
	task := &testproto.Task{
		Title: "test",
	}
	require.True(t, mask.IsValid(task))
	protoMask, err := fieldmask_utils.MaskFromProtoFieldMask(mask, func(s string) string { return generator.CamelCase(s) })
	require.Nil(t, err)
	m := make(map[string]any)
	err = fieldmask_utils.StructToMap(protoMask, task, m)
	require.Nil(t, err)
	assert.Equal(t, map[string]any{"Title": "test"}, m)
}

Try using generator.CamelCase(s) which converts a lower case field name (in the field mask) into a camel case (golang struct naming).

from fieldmask-utils.

marcoshuck avatar marcoshuck commented on June 16, 2024

Thanks for the information, will give it a try! We should probably add this test case as it would help future devs that find this issue.

I can take care of creating a PR for this test and adding some docs about the generator package (which I was completely unaware of).

from fieldmask-utils.

mennanov avatar mennanov commented on June 16, 2024

Resolved in PR #42

from fieldmask-utils.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.