-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
A record in the invalid state becoming valid keeps the same transaction #539
Conversation
@cyril-sf it looks like this has some merge conflicts. Can you rebase on master? |
Sure. |
I didn't get any conflicts, weird. Did I miss something? |
@wagenet I didn't get any conflicts either ... could you please verify? |
That's odd, it says it can be merged now. |
It's not odd, it's wonderful! |
@cyril-sf Is there anything I can help with on this? I've been trying a number of approaches to be able to correct and resubmit after a server validation failure and have yet to find anything that works. |
@Pansapien thanks for the help. I'm finishing another PR right now and should work on fixing this one before the end of the week. Hopefully the code will be ready next week and will be good enough to be accepted. But my company really needs this too, so I won't give up. |
Let's summarize where I am with this:
My solution was to move the record to the @wycats and @tomdale suggested to create a new bucket for erred records that could be retried (my understanding was that
I'm not sure to know how do you want to solve this problem. |
Is there anything new on this one? 😏 |
This is a feature that is very sorely needed. In the meantime, whats the alternative? How do I handle this scenario in my application? |
👍 for a way to solve this in current master |
Desperately need a fix for this. @cyril-sf anything I can do to help? |
Hi guys, I have a workaround that I have been using with success. It isn't (can't be!) the best way of doing things going foward. But I have created a mixin for these purposes. Gist: https://gist.github.com/intrica/4773420 The original SO question that I created in order to solve this: |
@seanrucker Sorry, I have been working on another PR for a while. I still plan to work on it once I'm done with the polymorphic associations. |
This is a pretty big one! Users often submit invalid data. I'm just learning ember-data, but quickly encountered this issue. Thanks, @intrica, for the gist! That was very informative. |
I have a super hacky fix for this in the meantime:
..at least for the Rails returning 422 because of validation errors issue. Yeah....awesome! : P |
I don't see why the record has to be taken out of its transaction upon the invalid -> uncommitted transition. In my case it causes a mess since the record thus gets added to the default transaction and when I submit the form (save gets called on the adapter) it submits all records in it. @cyril-sf 's above commit seems all that's needed. Instead of calling I'm also curious to see what does putting once-invalid records to a separate bucket (called |
@cyril-sf's commit helped fix my problem at http://stackoverflow.com/questions/15823481/ember-data-transactions-and-resubmitting-forms |
@cyril-sf What's the status of this? |
@tomdale I'm going to work on that. If anyone else wants to work on it, I'd be happy to help. But this is a big issue and someone needs to tackle it. |
@wulftone Thanks for sharing your hacky solution, btw. It really helped me move on from this situation quickly. |
I'd happy to lend a hand but first I'd have to understand what's the desired behavior and the reasons behind it (see my comments above). |
@cyril-sf What are the remaining tasks needed for the PR to become ready to be merged ? You previously wrote you were not sure about how the team wanted it to be done, is there an update on this specific point ? |
@balinterdi agreed. @ybart This PR may be to specific, there are other areas that would need a robust error handling. Another frequent use case, is when you get a 500. You end up with a "zombie" record. The goal would be to list those use cases and design a solution that will lead us to fix them all, even if it is separated in several PR. So the first step is really to list the error use cases. |
New to ember-data and ran into this today. Would be nice to see this merged, even if it's not the final solution (as mentioned in the above comment). Update Thanks @wulftone for your hacky fix. Worked perfectly for me. |
@cyril-sf could you check if this is resolved ? |
@sly7-7 The test that I have written doesn't pass in master with that commit. I'll take a look at this code durig the weekend. Hopefully something good will come out of it. |
This would be great, thanks a lot :) |
@cyril-sf I think this is fixed by transactions refactoring. Could you confirm that? |
@tchak Confim! The record stayed attached to the transaction and can be attached to another one! Thanks! |
@wulftone Your hack worked for me as well! Dang! I've been searching for a workaround for two days. How is it possible that this was overlooked? Obviously you need server side validation. According to the code, ember data expects a 422 for validation errors. But regardless whether it's a 422 or 500, the model is hosed, albeit in different ways. It should be easy to try to commit again. model.send('becameValid') goes against the grain in so many ways...a model shouldn't be valid if it's technically invalid. Plain a simple: a model in an invalid state should be able to commit. |
This is fixing the issue "unable to reuse a transaction on an invalid record"
[Fixes #457]