New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add note about casing #1840

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@NullVoxPopuli
Contributor

NullVoxPopuli commented Jul 12, 2016

I was surprised by this when I was playing with fields.

@mention-bot

This comment has been minimized.

Show comment
Hide comment
@mention-bot

mention-bot Jul 12, 2016

@NullVoxPopuli, thanks for your PR! By analyzing the annotation information on this pull request, we identified @luizkowalski to be a potential reviewer

mention-bot commented Jul 12, 2016

@NullVoxPopuli, thanks for your PR! By analyzing the annotation information on this pull request, we identified @luizkowalski to be a potential reviewer

@NullVoxPopuli

This comment has been minimized.

Show comment
Hide comment
@NullVoxPopuli

NullVoxPopuli Jul 12, 2016

Contributor

Actually, I found a bug,
This works:

      search = @event.attendances.includes(:attendee).ransack(search_params)
      return render json: search.result, fields: { 'event-attendance' => [:attendee_name] }

but this doesn't work:

      search = @event.attendances.includes(:attendee).ransack(search_params)
      return render json: search.result, fields: { 'event-attendance' => ['attendee-name'] }

the casing consistency is all over the place. :-\

Contributor

NullVoxPopuli commented Jul 12, 2016

Actually, I found a bug,
This works:

      search = @event.attendances.includes(:attendee).ransack(search_params)
      return render json: search.result, fields: { 'event-attendance' => [:attendee_name] }

but this doesn't work:

      search = @event.attendances.includes(:attendee).ransack(search_params)
      return render json: search.result, fields: { 'event-attendance' => ['attendee-name'] }

the casing consistency is all over the place. :-\

@NullVoxPopuli NullVoxPopuli added this to the 1.0 milestone Jul 12, 2016

@bf4

This comment has been minimized.

Show comment
Hide comment
@bf4

bf4 Aug 9, 2016

Member

@NullVoxPopuli could you add a note about this or a test maybe? Or maybe the note should be that the key transform doesn't affect how .... the ... original field names?

Also, missing changelog and [ci skip] unless you're adding a test

Member

bf4 commented Aug 9, 2016

@NullVoxPopuli could you add a note about this or a test maybe? Or maybe the note should be that the key transform doesn't affect how .... the ... original field names?

Also, missing changelog and [ci skip] unless you're adding a test

@NullVoxPopuli

This comment has been minimized.

Show comment
Hide comment
@NullVoxPopuli

NullVoxPopuli Aug 9, 2016

Contributor

yup, will do

Contributor

NullVoxPopuli commented Aug 9, 2016

yup, will do

@NullVoxPopuli

This comment has been minimized.

Show comment
Hide comment
@NullVoxPopuli

NullVoxPopuli Aug 9, 2016

Contributor

changeog entry added.

Contributor

NullVoxPopuli commented Aug 9, 2016

changeog entry added.

@@ -29,3 +29,5 @@ render json: @user, fields: { users: [:access_token] }
```
Where `users` is the JSONAPI type.
Casing for multi-word fields should match the casing specified for `ActiveModelSerializers.config.key_transform`.

This comment has been minimized.

@bf4

bf4 Aug 10, 2016

Member

@NullVoxPopuli Can you clarify with an example and explanation of how to thing about which casing to choose?

e.g.

# BAD, will not work because.... key_transform is x, field name is y, adapter is z, serializer attribute is q, etc.
render json: search_result, fields: { 'event-attendance' => [:attendee_name] }

# GOOD, will work because...key_transform is x, field name is y, adapter is z, serializer attribute is q, etc.
render json: search_result, fields: { 'event-attendance' => ['attendee-name'] }
@bf4

bf4 Aug 10, 2016

Member

@NullVoxPopuli Can you clarify with an example and explanation of how to thing about which casing to choose?

e.g.

# BAD, will not work because.... key_transform is x, field name is y, adapter is z, serializer attribute is q, etc.
render json: search_result, fields: { 'event-attendance' => [:attendee_name] }

# GOOD, will work because...key_transform is x, field name is y, adapter is z, serializer attribute is q, etc.
render json: search_result, fields: { 'event-attendance' => ['attendee-name'] }

This comment has been minimized.

@NullVoxPopuli

NullVoxPopuli Aug 10, 2016

Contributor

yeah, I may need to add tests and / or reference my other PR that adds tests to refresh myself on what was happening

@NullVoxPopuli

NullVoxPopuli Aug 10, 2016

Contributor

yeah, I may need to add tests and / or reference my other PR that adds tests to refresh myself on what was happening

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment