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

Fix enum-typed MySQL feilds #21

Closed
wants to merge 1 commit into from

Conversation

deadtrickster
Copy link

Mariaex returns strings for fields defined as enum(...)

Unfortunately I still unable to reflect this in tests since I don't know how to create migration with enum field type. Asked in #elixir-lang (IRC, Slack).

@gjaldon
Copy link
Owner

gjaldon commented Oct 12, 2016

@deadtrickster it returns as string prolly because you set the column as string instead of integer?

@deadtrickster
Copy link
Author

Well, ENUM values are always strings, aren't they?

Excerpt from the manual (http://dev.mysql.com/doc/refman/5.7/en/enum.html):

CREATE TABLE shirts (
    name VARCHAR(40),
    size ENUM('x-small', 'small', 'medium', 'large', 'x-large')
);

@gjaldon
Copy link
Owner

gjaldon commented Nov 6, 2016

@deadtrickster EctoEnum doesn't currently support MySQL Enum types but it does for Postgres. Feel free to contribute that though if you want. I plan to work on it but not anytime soon. For now, you'll need to use integer columns.

@gjaldon
Copy link
Owner

gjaldon commented Nov 6, 2016

Closing this and created an issue #24

@gjaldon gjaldon closed this Nov 6, 2016
@deadtrickster
Copy link
Author

Feel free to contribute

Could you please tell me what's wrong with this PR?

@gjaldon
Copy link
Owner

gjaldon commented Nov 7, 2016

@deadtrickster we currently do not support strings in EctoEnum and supporting it would require a bit more code than that. For example, here's a pending PR that aims to support string-backed enums https://github.com/gjaldon/ecto_enum/pull/9/files

@deadtrickster
Copy link
Author

Thank you for the reply.

Yeah my "fix" is pretty simple and I'm glad it works for me. PR you linked does a little bit more indeed. Like String.to_atom 😱.

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.

None yet

2 participants