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

RealColumn - toDouble convert error on Select #33

Closed
raphmte opened this issue Jun 11, 2019 · 3 comments
Closed

RealColumn - toDouble convert error on Select #33

raphmte opened this issue Jun 11, 2019 · 3 comments
Assignees

Comments

@raphmte
Copy link

raphmte commented Jun 11, 2019

If I create a column with type RealColumn and set it as nullable (), the insertion happens normally, but at the time of the select it generates an error saying that it is not possible to convert a null value to double. How can I solve this? I really need this column to be nullable.

RealColumn get sorStartTravelLon => real().named("sorStartTravelLon").nullable()();

E/flutter (10165): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: NoSuchMethodError: The method 'toDouble' was called on null. E/flutter (10165): Receiver: null E/flutter (10165): Tried calling: toDouble()

@simolus3 simolus3 self-assigned this Jun 11, 2019
@raphmte
Copy link
Author

raphmte commented Jun 11, 2019

Good morning, very good @simolus3 . Thanks for the correction. As you did not update in pud.dev I still made this change in hand here to be able to work.

Taking advantage of this post, could you give me an example of how to use withDefault () in column creation? I tried every way and I could not.

@raphmte raphmte closed this as completed Jun 11, 2019
@simolus3
Copy link
Owner

simolus3 commented Jun 11, 2019

Hi, I'll release a new version on pub.dev soon. Edit: New version is out, upgrading the packages should do the trick.

Regarding the usage of withDefault(): The idea is that you can pass any expression as a parameter, although the most useful ones would be a constant. For instance, if you wanted to have an int field with a default value, you could use integer().withDefault(const Constant(12)). However, more complex uses are possible. Let's say you could wanted a column that stores the time when the row was created: dateTime().withDefault(currentDateAndTime). Does that help? If you have a specific use case in mind I can try to tell you how that could be achieved by using withDefault.

@raphmte
Copy link
Author

raphmte commented Jun 12, 2019

Seriously, is it that simple? I've tried so many ways, I've read the documentation withDefault so many times and the only thing I did not try to do was put some Constant.

Thank you so much for this, will help me out more!

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