SeaQL / sea-orm

🐚 An async & dynamic ORM for Rust
https://www.sea-ql.org/SeaORM/
Apache License 2.0
7.3k stars 513 forks source link

Add column name when `error occurred while decoding: Null` #828

Closed dinhani closed 2 years ago

dinhani commented 2 years ago

Motivation

A common error I make is forgetting to map a nullable column using Option, so I receive the error message error occurred while decoding: Null.

I would like the have the column name in the error message so I can easily identify what column was mapped wrongly.

Proposed Solutions

It seems the column name is available in all places the Null error is generated, so it would be nice if the column name is passed to it as parameter, so it can be included in error message.

Additional Information

Example of code where col parameter exists and could be used to identify the column that failed with the Null message: https://github.com/SeaQL/sea-orm/blob/0c96e133250b7c8ab43a6a99931b82c95f59acc1/src/executor/query.rs#L346-L354

tyt2y3 commented 2 years ago

Thank you for your suggestion. I agree with that. PR is welcomed.

billy1624 commented 2 years ago

Hey @dinhani, welcome! Sorry for the delay! Yeah, it's definitely doable and making it much easier to debug.

billy1624 commented 2 years ago

For anyone who is reading this, I'll mark this issue as open for contributions :)

kyoto7250 commented 2 years ago

@billy1624

hello, Could you please assign me with this issue?

ikrivosheev commented 2 years ago

@kyoto7250 done)

kyoto7250 commented 2 years ago

@ikrivosheev

Thank you.

I will try it.

billy1624 commented 2 years ago

Thanks! @kyoto7250 let me know if you need any help along the way :) Feel free to open a draft PR