Skip to content

Commit

Permalink
Merge pull request #2263 from divine/fix-getrelation
Browse files Browse the repository at this point in the history
[3.8] Fix getRelationQuery breaking changes
  • Loading branch information
Smolevich committed May 27, 2021
2 parents a9b432b + 924c285 commit 6aa6ad1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 76 deletions.
38 changes: 0 additions & 38 deletions src/Relations/HasMany.php
Expand Up @@ -17,15 +17,6 @@ public function getForeignKeyName()
return $this->foreignKey;
}

/**
* Get the plain foreign key.
* @return string
*/
public function getPlainForeignKey()
{
return $this->getForeignKeyName();
}

/**
* Get the key for comparing against the parent key in "has" query.
* @return string
Expand All @@ -45,35 +36,6 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery,
return $query->select($foreignKey)->where($foreignKey, 'exists', true);
}

/**
* Add the constraints for a relationship count query.
* @param Builder $query
* @param Builder $parent
* @return Builder
*/
public function getRelationCountQuery(Builder $query, Builder $parent)
{
$foreignKey = $this->getHasCompareKey();

return $query->select($foreignKey)->where($foreignKey, 'exists', true);
}

/**
* Add the constraints for a relationship query.
* @param Builder $query
* @param Builder $parent
* @param array|mixed $columns
* @return Builder
*/
public function getRelationQuery(Builder $query, Builder $parent, $columns = ['*'])
{
$query->select($columns);

$key = $this->wrap($this->getQualifiedParentKeyName());

return $query->where($this->getHasCompareKey(), 'exists', true);
}

/**
* Get the name of the "where in" method for eager loading.
* @param \Illuminate\Database\Eloquent\Model $model
Expand Down
38 changes: 0 additions & 38 deletions src/Relations/HasOne.php
Expand Up @@ -26,15 +26,6 @@ public function getHasCompareKey()
return $this->getForeignKeyName();
}

/**
* Get the plain foreign key.
* @return string
*/
public function getPlainForeignKey()
{
return $this->getForeignKeyName();
}

/**
* @inheritdoc
*/
Expand All @@ -45,35 +36,6 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery,
return $query->select($foreignKey)->where($foreignKey, 'exists', true);
}

/**
* Add the constraints for a relationship count query.
* @param Builder $query
* @param Builder $parent
* @return Builder
*/
public function getRelationCountQuery(Builder $query, Builder $parent)
{
$foreignKey = $this->getForeignKeyName();

return $query->select($foreignKey)->where($foreignKey, 'exists', true);
}

/**
* Add the constraints for a relationship query.
* @param Builder $query
* @param Builder $parent
* @param array|mixed $columns
* @return Builder
*/
public function getRelationQuery(Builder $query, Builder $parent, $columns = ['*'])
{
$query->select($columns);

$key = $this->wrap($this->getQualifiedParentKeyName());

return $query->where($this->getForeignKeyName(), 'exists', true);
}

/**
* Get the name of the "where in" method for eager loading.
* @param \Illuminate\Database\Eloquent\Model $model
Expand Down
1 change: 1 addition & 0 deletions tests/QueueTest.php
Expand Up @@ -39,6 +39,7 @@ public function testQueueJobLifeCycle(): void
'job' => 'test',
'maxTries' => null,
'maxExceptions' => null,
'failOnTimeout' => false,
'backoff' => null,
'timeout' => null,
'data' => ['action' => 'QueueJobLifeCycle'],
Expand Down

0 comments on commit 6aa6ad1

Please sign in to comment.