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

diesel generated schema.rs does not include Mapping suffix for enum types #56

Closed
chris13524 opened this issue Dec 18, 2020 · 2 comments
Closed

Comments

@chris13524
Copy link

chris13524 commented Dec 18, 2020

According to the getting started page on Diesel's docs the schema.rs file is typically automatically created/updated by diesel setup or diesel migration run.

The problem is that the schema.rs that it generates does not include the proper Mapping suffix for enum types. This results in errors similar to this.

I am able to work around this issue by adding a patch_file to diesel.toml, but I would prefer to avoid this.

@adwhit
Copy link
Owner

adwhit commented Dec 18, 2020

Yes, this is definitely annoying and I myself came up against it this week. However, it is a result of how Diesel chooses to mangle the names of types it does not recognize - it uses Title_case i.e. foo -> Foo but foo_bar -> Foo_bar. There is no consistent way to map this to the type this crate generates.

I think the real solution would be to offer a PR to Diesel to allow you to specify the name mangling rule in your diesel.toml. However I haven't really thought about how this might work.

As a workaround, if you make sure your enums are always TwoWords then you can use #[DieselType = "Two_words"] and it should work, or else use a patch file as you suggested.

@adwhit
Copy link
Owner

adwhit commented Dec 18, 2020

You could also try re-exporting the mapping types in a different modules, as described in #53 . That allows you to alias the mapping types to whatever diesel expects them to be.

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