You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the first layer, this works great. For example, passing [:id, :things] to @only works perfectly. Passing nothing to @only results in me getting the full Foo object too, which is exactly what I want.
The issue arises when I pass [:id, :things, {:foo => [:foo_name]}]. Instead of the expected id, things, and foo hash containing foo_name, I get back id, things and a foo hash containing just the foo object's id.
The text was updated successfully, but these errors were encountered:
BUT the actual check for whether or not the key should be included is just only_fields.key?(key). Which fails for foo_name, since it isn't a key of only_fields. Anything nested the way the README shows isn't going to work.
Even worse though, is that the id is returning in my above example. This is caused by the fact that it's just looping over all of the keys in each exposure and trying them against only_fields. What that means is anything that shares a key is going to show up (in my case because I want the bar id).
Is there a way to know which object we're comparing the key to? Or maybe even just if we could know if it's supposed to be nested at all?
So I've narrowed it down a little more. I don't 100% understand everything that's going on, but it looks like when serializable_hash is called for my nested object the options[:only] field (which is correct) is being overridden by the options.merge(runtime_options || {}) line.
If the override wasn't happening, it works correctly. The only_fields variable from my previous comment is populated with just the things it should be and so it works just fine. If I just make opts = options it seems golden.
I have a couple entities that look like this:
In the resource for
Bar
, I'm doingFor the first layer, this works great. For example, passing
[:id, :things]
to@only
works perfectly. Passing nothing to@only
results in me getting the fullFoo
object too, which is exactly what I want.The issue arises when I pass
[:id, :things, {:foo => [:foo_name]}]
. Instead of the expectedid
,things
, and foo hash containingfoo_name
, I get backid
,things
and a foo hash containing just the foo object'sid
.The text was updated successfully, but these errors were encountered: