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

Problem with foreign key constraint #49

Closed
nakoda opened this issue Feb 23, 2018 · 6 comments
Closed

Problem with foreign key constraint #49

nakoda opened this issue Feb 23, 2018 · 6 comments
Labels

Comments

@nakoda
Copy link

nakoda commented Feb 23, 2018

Its working fine with cakephp 3.5 till user is login. but how to set NULL (not 0) for not login users.

In simple words how to save fields (created_by, modified_by) with NULL not the 0.

This is the case where user can fill form with or without login and system need to track user if it is login else it should enter NULL (not zero).

@tomisykora
Copy link

Same issue here. Have you find a solution for this?

@ADmad
Copy link
Member

ADmad commented Nov 23, 2018

I assume you'll have set DEFAULT NULL for the foreign key field in database. Ideally if there's no logged in user that the field should either be set to null or not touched at all. Someone needs to figure out why/where 0 is being set for the field. Patch to fix is welcome.

@ADmad ADmad added the bug label Nov 23, 2018
@tomisykora
Copy link

Column's default is set to NULL so i'm trying to debug it why is it trying to set the footprint to 0 but still no luck...

@tomisykora
Copy link

tomisykora commented Nov 23, 2018

@ADmad so i think i've found the issue. In FootprintBehavior.php when injecting entity if there's no value in $options the current() function returns false so i think that's why it is trying to set the user to 0. So i've put the check there and it's working correctly for logged in user and non-logged in user but it could break somehting else... 😄

@ADmad
Copy link
Member

ADmad commented Nov 23, 2018

@t0mi Nice, if you can make a pull request with your chance we can review it 🙂.

@tomisykora
Copy link

tomisykora commented Nov 23, 2018

@ADmad Just did

@ADmad ADmad closed this as completed Nov 23, 2018
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

3 participants