Skip to content

undefined method getRelationWithoutConstraints() with v3.2.3 #1305

@rimantoro

Description

@rimantoro

When I'm updating Jenseggers MongoDB from v3.2.2 to v3.2.3, my test always return an error. Below is one of the error debug sample :

PHPUnit 4.8.36 by Sebastian Bergmann and contributors.

E

Time: 390 ms, Memory: 16.00MB

There was 1 error:

1) InvalidPromoUsageTest::testInvalidMaxUsagePromo
BadMethodCallException: Call to undefined method Illuminate\Database\Query\Builder::getRelationWithoutConstraints()

/home/imanovski/www/sepulsa/meowth.sepulsa.dev/vendor/illuminate/database/Query/Builder.php:2448
/home/imanovski/www/sepulsa/meowth.sepulsa.dev/vendor/illuminate/database/Eloquent/Builder.php:1465
/home/imanovski/www/sepulsa/meowth.sepulsa.dev/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php:28
/home/imanovski/www/sepulsa/meowth.sepulsa.dev/vendor/illuminate/database/Eloquent/Builder.php:900
/home/imanovski/www/sepulsa/meowth.sepulsa.dev/vendor/illuminate/database/Eloquent/Model.php:3551
/home/imanovski/www/sepulsa/meowth.sepulsa.dev/vendor/illuminate/database/Eloquent/Model.php:3565
/home/imanovski/www/sepulsa/meowth.sepulsa.dev/app/Models/Promo/Promo.php:418
/home/imanovski/www/sepulsa/meowth.sepulsa.dev/tests/promo/InvalidPromoUsageTest.php:1173

When I rollback to v3.2.2, everything is passed.

I'm debuging line-by-line then found something weird, because the method is not (or should not) related with MongoDB

public static function getByPromocode($code)
    {
        ### This line will raised error when using v3.2.3, but not in v3.2.2
        ### This a sample method from a model that didnt use Jensegger MongoDB
        $me = self::select('id')->whereHas('promocodes', function($q) use ($code) {
            $q->where('promocodes.code', $code);
        })->first();
        if($me) {
            return self::getById($me->id);
        } else {
            return null;
        }
    }

Does anybody have some issue and have the solution else than rollback to 3.2.2 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions