RatkoR / laravel-crate.io

Crate.io driver for Laravel
MIT License
36 stars 12 forks source link

Upgrade to Laravel 8 #36

Closed olavski closed 4 years ago

olavski commented 4 years ago

It is that time again...

Would you have time to update the dependencies to make this package compatible with Laravel 8?

Cheers!

RatkoR commented 4 years ago

Yes, I'll try. Crate's pdo requires guzzle 6 and laravel 8 requires guzzle 7. I'll see if they can match 7 too...

RatkoR commented 4 years ago

Crate have updated their guzzle version and we're ok to go.

I've created a laravel-8.X branch. @olavski any chance you can try it out.

All tests here in the repo pass. Our internal tests also pass.

There is one strange thing in crate-pdo: it used to throw a QueryException if one tried to store an object into string field and it seems they allow it now: see here what I mean. This is why I'd like one more person to test it before I push it to master.

olavski commented 4 years ago

Great! Thank you for your work on this!

I will test it out and get back to you.

RatkoR commented 4 years ago

@olavski did you find time to test it?

olavski commented 4 years ago

Hi!

I tested it with one of my applications and everything worked fine there.

I started setting up a fresh laravel app to test out common use cases and also the thing about storing an object into string field, but I didn't have time to complete it. I will try to complete it this weekend.

The issue with storing an object into string field shouldn't be an issue for me as I'm not using it anywhere.

RatkoR commented 4 years ago

Ok, I'll merge it into master early next week then. Thx!

olavski commented 4 years ago

Hi,

I did some more testing and I didn't run into any issues, so please merge this when you have the time.

As Laravel can cast fields do different types it can be useful to store objects as strings. If you try to store an array without defining it in $casts it throws an Exception, and I think ideally it should do the same for objects, but it might not be an issue.

class TestModel extends Eloquent 
{
    protected $casts = [
        'object_field' => 'object',
        'array_field' => 'array',
    ];
}
$foo = new \stdClass();
$foo->bar = 'test';
$foo2 = ["test1", "test2"];

$test = TestModel::create([
    'object_field' => $foo,
    'array_field' => $foo2,
]);

dump($test->object_field): // returns object
dump($test->array_field): // returns array
RatkoR commented 4 years ago

Done, v10 is released.

Thank you @olavski !