-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Eloquent ORM goes OOM on delete() for a model without primary key #3761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That's odd, but it's worth noting that |
What column is it supposed to delete with ? |
If there is no primary key, it could delete specifying all columns. In any case, it should not fail with OOM but with a more meaningful error. |
If you were to implement that, |
That is true but it's not like you can accidentally put this into the code. Cases of models without primary key are rare anyway. How about implementing |
@DSpeichert , you can use an array as a PK. |
@anlutro Checking (not that I think this should be implemented. Just saying). |
Fixed. |
Still doesn't work. class Article extends \Eloquent
{
use \Illuminate\Database\Eloquent\SoftDeletingTrait;
public $incrementing = false;
protected $primaryKey = [
'article_id',
'publisher_id'
]; $item = Article::where('article_id', 1)->where('publisher_id', 1)->first();
// works fine
$item->delete();
// throws Exception Result:
public function getAttribute($key)
{
$inAttributes = array_key_exists($key, $this->attributes); |
@YOzaz is right, I get the same exception. I think Eloquent expects a string primary key to delete there, and can't handle cases where the primary key is a composite defined through an array (where it should add multiple constraints in the |
For a model with:
when
$instance->delete()
is called, it fails with out of memory fatal error.The text was updated successfully, but these errors were encountered: