-
Notifications
You must be signed in to change notification settings - Fork 354
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
Value.ofNullable has a wrong assertion #2280
Comments
The point of the
In other words, a If you have nullable columns and you want to interpret null as absent instead of setting the column to null, you'll have to spell out |
I also find this constructor name very confusing. It's silly that a constructor named /// The functionality is equiavalent to the following:
/// `x != null ? Value(x) : Value.absent()`.
|
The documentation also points out that the constructor should only be used when
The parameter can be null just fine, the type parameter is the problem. You can't do |
I agree with @praxder. When would this be applicable? For instance, if I'm certain that the value I'm inserting isn't nullable, I would simply use Value() instead of Value.ofNullable(). |
It's applicable when you have a non-nullable column which you may or may not want to update. Then you can use |
Alright, I understand now. Thank you for clarifying. |
Are you considering adding a feature to handle nullable values? For instance, something like a wrapper for this: String? polygonId; final newSublot = SublotsCompanion( await _farmsUseCase.insertSublot(newSublot); |
Yeah, I think I'll add a |
Describe the bug
it says that
Value<T>.ofNullable constructor
is to Create a value that is absent if value is null and [present] if it's not. and also The functionality is equiavalent to the following:x != null ? Value(x) : Value.absent()
But the problem is the assertion blocked the functionality:
Why
Value.ofNullable(null) can't be used for a nullable T,
?? This assertion should be removed so we can use this construction to the equivalent functionalityx != null ? Value(x) : Value.absent()
The text was updated successfully, but these errors were encountered: