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

defaultValue doesn't work on update replace #34

Closed
MohiuddinM opened this issue Jun 11, 2019 · 8 comments
Closed

defaultValue doesn't work on update replace #34

MohiuddinM opened this issue Jun 11, 2019 · 8 comments
Assignees

Comments

@MohiuddinM
Copy link

default value doesn't work when an existing row is being replaced, with another row where a required field is null

@simolus3
Copy link
Owner

Can you give me some more details in what you're trying to achieve? Reset a value to that you have defined in withDefault?

@MohiuddinM
Copy link
Author

I have created a value in database, and now I want to replace that value with a new object (which was created using the fromJson method)

@MohiuddinM
Copy link
Author

I am using update(xxx).replace(aaa)

@simolus3
Copy link
Owner

Sorry for the delay, but I think I still need more info. UpdateStatement.replace should set fields that are null back to null in the database. If that's not happening it would be a bug in the library. If you need a different behavior, please explain what you'd expect to happen.

@MohiuddinM
Copy link
Author

I would expect the replace function to work exactly as create function. Remove the old row, and create a new row in its place.

@simolus3 simolus3 self-assigned this Jun 16, 2019
@simolus3
Copy link
Owner

Sorry for the delay. This is pretty much the same problem as in #25. If a column is set to null we can't know if that's null as in "reset to the default value" or "override this column to NULL".

@MohiuddinM
Copy link
Author

This is only a problem, when the attribute is nullable. Secondly, I have read your comment on #25 too, and I would simply disallow default values for nullable attributes if I were you.

@simolus3
Copy link
Owner

This is now implemented on develop - absent values will be replaced with their default value.

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

No branches or pull requests

2 participants