Skip to content
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

[Bug] Deleting last relation tries to update this record and throws an error #4204

Closed
howest-ward opened this issue Feb 16, 2022 · 5 comments
Assignees
Labels

Comments

@howest-ward
Copy link

Bug report

What I did

I added a relationship with multiple fields. I can add multiple relationship records.
When I delete a relationship record it works exept when I try to delete the last record.
Then it tries to update this record with an empty parent Id, and thus throwing an error "Cannot insert the value NULL into column ..."

What I expected to happen

Delete the record and not update with emtpy parent ID

Is it a bug in the latest version of Backpack?

Yes

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

PHP VERSION:

PHP 7.4.21 (cli) (built: Jul 1 2021 16:09:23) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies

LARAVEL VERSION:

v8.83.1@bddba117f8bce2f3c9875ca1ca375a96350d0f4d

BACKPACK VERSION:

5.0.6@2be4ff8407259f528a3541f0569ce156bab63165

@pxpm
Copy link
Contributor

pxpm commented Feb 16, 2022

@howest-ward I think I am fixing this. Just pushed the branch to github! #4205

Can you see if it's the same thing ?

Thanks,
Pedro

@pxpm pxpm self-assigned this Feb 16, 2022
@howest-ward
Copy link
Author

I am not sure how to test a pull request locally, but it looks the same problem. I use composer to install backpack, can I test pull requests on this code?
The 'force_delete' => true, also works

@pxpm
Copy link
Contributor

pxpm commented Feb 16, 2022

Hey @howest-ward !

Fastest way is to change your composer.json and in your required section, change the backpack/crud line to: "backpack/crud": "dev-fix-hasmany-fallbacks-and-defaults as 5.0.99", and then composer update.
image

The rule is: prefix the branch name with dev- when the branch is not tagged (as is the case with all our dev branches), and use a version alias (composer thinks that we are downloading 5.0.99) and don't complain about dependency issues.

In this case, since this PR is very recent it has the last code available in v5 plus the fix. you can use it until we merge the branch, when we do you just need to revert the composer.json back to initial state to pick v5 source branch. "backpack/crud": "^5.0",

Hope it helps 👍

Cheers, Pedro

@howest-ward
Copy link
Author

Thanks, learned something today!
I downloaded the changes as explained, removed the 'force_delete' => true and the problem is gone!
Solved!

@pxpm
Copy link
Contributor

pxpm commented Feb 16, 2022

Going to close, let's keep the conversation in the PR thread if needed!

Thanks again @howest-ward

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants