enum type deprecated?

enum type deprecated?

by Joseph Rézeau -
Number of replies: 1
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi all,

In Moodle 2, the enum type has been deprecated in the database fields. I am currently updating two of my personal sites and I notice that I am using the enum type in my mysql databases.

Why did Moodle 2 deprecate the enum type? Is an internal decision, proper to Moodle? It the enum type going to be deprecated in mysql/mysqli in general or is it safe to continue using (outside of Moodle)?

Joseph

Average of ratings: -
In reply to Joseph Rézeau

Re: enum type deprecated?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

It was an internal decision. It was a long time ago, but I think the reasons were these:

  • Enums are a trade-off. The constraint that a column can only hold certain values can detect some bugs, but at the cost of maintaining the constraint.
  • One part of the cost is that some changes which used to be simple (e.g. adding a new way to number choices in multiple choice questions) which would have been simple now involve a DB upgrade, which is complex.
  • Another part is that Moodle needs to support 4 databases, MySQL, Postgres, MS SQL and Oracle, and I think they all implement enums in a different way, which makes it hard to do in Moodle.

So, eventually the decision was made that in Moodle, the trade off was better without enums, and they were removed. However, the trade-off might be different in your app.

Average of ratings: Useful (1)