Enums are weird #database #mysql #coding

preview_player
Показать описание
Enums are great for listing out specific choices because they give you the readability of a string but the underlying storage of an integer. There are a few gotchas though!
Рекомендации по теме
Комментарии
Автор

What in the JavaScript is happening here?😂

milesstripling
Автор

I never use enums because adding new ones or redefining them is a total pain. It's a lot easier to do this at the application layer

spicynoodle
Автор

You can refer this col in queries using the underline integer value instead the of the string value that's the BIG advantage of the ENUMS, as everything in code, so that later you can change the string value without affect the written code.
Thanks

MrNiceGuy
Автор

Yes, Enums in MySQL is a total mess and it just creates so many problems. Just adding one new option is a pain and that doesn't even work properly with Laravels migrations. It's much better with a varchar + index, or in some cases a tinyint and then manage the constraints in the application layer. You still have to validate the data before inserting so it is not really any additional work.

Pekzr
Автор

so to fix that would
max(size+0)
work?

monq
Автор

What’s this client software you’re using?

gabrielbianchi
Автор

@PlanetScale I have problems with ENUM, that should allow null values. Did you face it as well and do you have any tricks and advice on how to handle it properly?

ArtemKhodos
Автор

I’ll keep using type tables instead, thx

SpadeQc
visit shbcf.ru