Skip to content

First argument of MongoDB\Laravel\Query\Builder::where must be a field path as "string". Got "null" #2725

Closed as not planned
@clarkeash

Description

@clarkeash
  • 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions