First argument of MongoDB\Laravel\Query\Builder::where must be a field path as "string". Got "null"
clarkeash opened this issue · comments
- Laravel-mongodb Version: 4.1.1
- PHP Version: 8.3.2
- Database Driver & Version: 1.17.2
Description: I am currently upgrading to Laravel 10 and v4 of this library and when calling save on an embeded document I get the error: First argument of MongoDB\Laravel\Query\Builder::where must be a field path as "string". Got "null"
Steps to reproduce
I have the following models (simplified for clarity)
class Account extends Model {
public function stripe(): EmbedsOne
{
return $this->embedsOne(Stripe::class);
}
}
class Stripe extends Model {}
Then when I try to update the stripe subdocument like so:
$account = Account::find(...);
$stripe = $account->stripe;
$stripe->subscription = ['some data'];
$stripe->save();
Expected behaviour
Tell us what should happen jenssegers/mongodb
3.9 it would save the data just fine.
Actual behaviour
1) Tests\Feature\Actions\Stripe\CancelPendingChangeTest::it_will_cancel_a_pending_modification
InvalidArgumentException: First argument of MongoDB\Laravel\Query\Builder::where must be a field path as "string". Got "null"
/Users/clarkeash/code/sites/billing/vendor/mongodb/laravel-mongodb/src/Query/Builder.php:1012
/Users/clarkeash/code/sites/billing/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:302
/Users/clarkeash/code/sites/billing/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1254
/Users/clarkeash/code/sites/billing/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1213
/Users/clarkeash/code/sites/billing/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1130
/Users/clarkeash/code/sites/billing/vendor/mongodb/laravel-mongodb/src/Eloquent/Model.php:737
/Users/clarkeash/code/sites/billing/app/Actions/Stripe/StoreSubscriptionInformation.php:82
/Users/clarkeash/code/sites/billing/vendor/lorisleiva/laravel-actions/src/Concerns/AsObject.php:24
/Users/clarkeash/code/sites/billing/tests/Feature/Actions/Stripe/CancelPendingChangeTest.php:41
I am unsure if this is a bug or if I have missed something, can you point me in the right direction? Thanks
Hi, we have a test for the embedOne feature, but it seems that your use-case is not covered.
Tracking this issue in Jira to investigate. PHPORM-144
Strange, I will try and put together a reproducible case for you
Hi @clarkeash, were you able to find a reproducer?
Closing as I can't reproduce. I can reopen if you can provide a reproducer.
Okay fair enough, I have not had the time to reproduce it as I have a workaround.