ruby-grape / ruby-grape/grape-entity

The serialized hash from `represent` can like back to the original ActiveRecord data when using PostgreSQL native types like `JSON` or `HStore`

Open
#200 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug?
Dominant language
Ruby
Stars
729
Forks
154
PR merge metrics
No merged PRs in 30d

Description

First off, I am not sure that GrapeEntity is the place to fix this. But we should talk about this here at least.

When an object is serialized I would expect the serialization to produce a copy of the data in the object. Modifying the serialized hash should not modify the original object.

This is not the case if the original object contains a hash, for example when an ActiveRecord Model object contains JSON or an HStore. Modifying that data in the resultant serializable hash actually modifies the original JSON or HStore data on the active record object.

In order to protect the integrity of these datatypes I've resorted to the exposing a "dup'd" version of the object.

Thoughts?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by locating the represent serialization path and reproduce the behavior with an ActiveRecord object containing PostgreSQL JSON or HStore data; done means modifying the serialized hash no longer changes the original object.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, ruby
Domain
api, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.