-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[5.1] Update hydrate to handle binary stream resources #10857
Conversation
`Eloquent->hydrate` now runs `stream_get_contents` on resource columns before passing them into the model. This resolves an issue where it is impossible to adequately deal with binary data from PostgreSQL. #10847
// type casting without any headache or checking which database | ||
// system we are using before doing business logic. | ||
// | ||
// See: https://github.com/laravel/framework/issues/10847 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't link to issues please.
@GrahamCampbell thanks for the feedback mate. |
What if we handle stream/resource using cast. Would it do the trick? |
@crynobone No, I don't think so. Review my ticket and the trouble I'm having with PostgreSQL and binary. To get binary working with PostgreSQL and Laravel I have to ...
The easiest, Occam's razor approach is what I've done. This simply unwraps the data from the stream so that the cache driver works without any problems, but forces the user to make sure that the data in the attributes array is what should be sent to the database using Eloquent mutators. The best possible fix for this would be to have a database driver method that can be used to wrap and unwrap information, possibly using type casting. The problem with type casting is that it's basically just a streamlined attribute mutator that doesn't stop the caching issue. The difference between binary for MySQL and binary for PostgreSQL is a great deal (because you have to wrap/unwrap and unstream as I described). However, I don't see a way for that to be done with existing architecture. I didn't want to go ahead and rewrite your PostgreSQL driver code for fear of wasting a lot of time I don't have to give only to have it rejected. I could do that later, but for right now, what I need is in that trait I linked. This code would help a lot of PostgreSQL people in the mean time. I really hope all this makes sense. It's taken me a week to get this far. |
To elaborate, you would send ip This, inserted into PostgreSQL, causes issues. It throws an error. To get it to work, you must use THIS is what must be inserted into PostgreSQL. However, on select, it returns a bizarre This is unusable, obviously, so we must also Now that we're back to binary, we can use My fix doesn't deal with most of that, it only deals with making sure that we never have a |
Seems like you could use a mutator and be more efficient here and achieve the same purpose. We don't want to spin through every attribute of every result looking for resource types. |
@taylorotwell No mate, read what I wrote. The Cache object does not call mutators. You have to either update your Cache manager to unpack streams, or improve your Database interfaces so they unpack streams (which is the best option). |
How does the cache play into this? On Fri, Nov 13, 2015 at 4:25 PM, Josh notifications@github.com wrote:
|
Because the I really tried everything to avoid changing framework functions, but binary values collected from PostgreSQL are completely worthless in Laravel. They have to be inserted with |
Post your actual code that is calling the cache. I want to see how you are On Fri, Nov 13, 2015 at 4:43 PM, Josh notifications@github.com wrote:
|
@taylorotwell See: #10847 (comment) I wrote out the entire exploration of this issue. |
So, has this still never been fixed? |
Eloquent->hydrate
now runsstream_get_contents
on resource columns before passing them into the model.This resolves an issue where it is impossible to adequately deal with binary data from PostgreSQL.
#10847