alvaroloes / enumer

A Go tool to auto generate methods for your enums
Other
480 stars 111 forks source link

Scanner and Valuer interface #2

Closed marcobeierer closed 8 years ago

marcobeierer commented 8 years ago

Hi,

thank you for your nice work at the enumer.

I have added a sql flag which allows to add a Scan and Value method to the enum to implement the Scanner and Valuer interface. This way the enum can be easily stored as string in the database and also be read from the database.

When someone is working with a database, in my opinion a string is compared to an int a more robust way to store the enum. Because the database integrity is not affected if an additional value is added to enum.

Please feel free to merge my changes if you like.

Best regards, Marco

marcobeierer commented 8 years ago

Sorry, there is an issue with the Scan method, does not work well.

alvaroloes commented 8 years ago

Hi!

Thank you very much for your pull request! I really appreciate it.

I agree that, although storing an integer in the DB is more efficient, using a string can be more readable and maintainable. This can also be optional with a flag.

I have just seen that you closed the pull request due to a misbehave in the Scan method. Feel free to reopen/create a new one when fixed and I'll be glad to review it and merge it.

Thanks again.

marcobeierer commented 8 years ago

Thank you for your reply.

I have now fixed the issue, but I will test it first in my production code, before I open a new pull request.

Best regards, Marco