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

feat(derive): add #[postgres(allow_mismatch)] #1026

Merged
merged 1 commit into from
Jul 23, 2023

Conversation

viniciusth
Copy link
Contributor

@viniciusth viniciusth commented Apr 30, 2023

As discussed on #1023, this PR implements an override/attribute that allows mismatching Rust and Postgres enums.

Example

#[derive(ToSql, FromSql)]
#[postgres(allow_mismatch)]
enum Mood {
    Sad,
    Happy,
    Meh,
}

@viniciusth viniciusth force-pushed the feature/allow-mismatch branch from 3d92ed1 to e71898f Compare April 30, 2023 13:55
@viniciusth
Copy link
Contributor Author

Hey @sfackler could you please review this PR?

if #allow_mismatch {
return true;
}

Copy link
Owner

Choose a reason for hiding this comment

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

I'd rather just not generate the match below at all if allow_mismatch is set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true, fixed!

@viniciusth viniciusth force-pushed the feature/allow-mismatch branch from e71898f to f5d5965 Compare June 19, 2023 01:53
@viniciusth viniciusth requested a review from sfackler June 19, 2023 01:54
@viniciusth viniciusth force-pushed the feature/allow-mismatch branch from f5d5965 to 258fe68 Compare June 19, 2023 01:57
@sfackler sfackler merged commit e7eb24a into sfackler:master Jul 23, 2023
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