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

Revamp Value to typed null value #107

Merged
merged 12 commits into from
Aug 21, 2021
Merged

Revamp Value to typed null value #107

merged 12 commits into from
Aug 21, 2021

Conversation

billy1624
Copy link
Member

@billy1624 billy1624 commented Aug 19, 2021

The problem

When using a prepared statement, the parameter binding must be of the same type as when prepared. As such, 0i32 is not compatible with None<bool>, it has to be None<i32>. To mitigate this, we have to remove the generic Null variant, and users have to indicate the associated type of the NULL.

The changes

It will be a rather big breaking change, but hopefully users would not have to change a lot of their existing code.
An upgrade guide will be provided afterwards.

@billy1624 billy1624 self-assigned this Aug 19, 2021
billy1624 added a commit to SeaQL/sea-orm that referenced this pull request Aug 19, 2021
@billy1624 billy1624 changed the title Typed Null Value Revamp Value Aug 19, 2021
@billy1624 billy1624 marked this pull request as ready for review August 20, 2021 09:21
#[cfg(feature = "with-chrono")]
Value::Date(_) => PostgresQueryBuilder.value_to_string(value).into(),
#[cfg(feature = "with-chrono")]
Value::Time(_) => PostgresQueryBuilder.value_to_string(value).into(),
#[cfg(feature = "with-chrono")]
Value::DateTime(_) => PostgresQueryBuilder.value_to_string(value).into(),
#[cfg(feature = "with-chrono")]
Value::DateTimeWithTimeZone(_) => PostgresQueryBuilder.value_to_string(value).into(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized it cannot compile if the Postgres backend is not enabled. I will refactor it later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!!

@tyt2y3 tyt2y3 merged commit 6d9f445 into master Aug 21, 2021
@tyt2y3 tyt2y3 deleted the typed-null-value branch August 21, 2021 11:57
@tyt2y3 tyt2y3 changed the title Revamp Value Revamp Value to typed null value Aug 21, 2021
tyt2y3 pushed a commit to SeaQL/sea-orm that referenced this pull request Aug 21, 2021
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

Successfully merging this pull request may close these issues.

2 participants