POST/PUT deeply nested data #382

Closed
wants to merge 13 commits into
from

4 participants

@joshbohde

This is some initial work on dealing with #307.

The first issue when sending deeply nested data is that a ToManys on a related resource would send a list to the orm for filtering, throwing a TypeError. This patch catches that, and will attempt a pk lookup instead.

Next, any ToManys that are nested would not be saved in save_m2m. This is handled via another hydrate_m2m + save_m2m after saving each object in the ToMany

I'm opening up this pull request now for review and ideas for more test cases.

joshbohde added some commits Nov 20, 2011
@joshbohde joshbohde Test for FieldError being generated when sending `resource_uri` in a …
…related resource.
e94fd9b
@joshbohde joshbohde Failing test for #307
Let's say we have 3 resources, A, B, and C, where A has a ToMany to B and B has a ToMany to C.

When creating or updating on A where the list of Bs is full (not a list of resource_uris), the list of Cs is passed to the ORM as a filter, which triggers a TypeError.
b5f1afd
@joshbohde joshbohde Cleanup print statement in test. 9cd75e5
@joshbohde joshbohde Catch the type error, and proceed to pk lookup.
Unfortunately, this causes a Django "DoesNotExist" in "./../tastypie/fields.py", line 56
bdae31e
@joshbohde joshbohde Fix improper setup of tests that was causing more issues. b6512bd
@joshbohde joshbohde Failing test for data not saving in nested levels. a3cc0a3
@joshbohde joshbohde I shouldn't copy-paste code. 4de115a
@joshbohde joshbohde Get the tests passing. 9019a32
@toastdriven

I'm actually working on this same region of code for #332 (& the security fixes). I have something slightly different, though functionally the same in mind. Mind if I steal the tests?

@joshbohde

Steal away.

@joshbohde

If you still want to steal these tests, I refactored and expanded them to test each individual combination of ToOne and ToMany separately.

@desimone

Did you get nested elements to work with this pull?

@toastdriven

Stolen into the perms branch, though the tests aren't passing yet. Still working on that. Thanks!

@achur achur referenced this pull request Jun 26, 2012
Closed

Generic relations #191

@osiloke

I dont understand why this is a fix because it does not account for form validation which means null values would get saved or am i missing something?

@toastdriven

Fixed as of SHA: d850758

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