-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Config] Enum node with 1 value not possible #15402
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
Comments
What is the use case for a configuration settings if it does not allow to change the value ? this is why the enum node enforces having a choice currently |
@stof apparently, @ro0NL starts with a proper parameter with several values, which is enum-compatible. However, the values of this parameter change frequently and sometimes they remove all values except one. Obviously at this point the parameter is not an enumeration, but it was previously and it will be again in the future. It's a pity that Symfony doesn't support 1-value enums, because they must change their application config when updating that parameter. |
At first sight, this feature request looks legit. It would be nice to know the behavior of "1 element enums" in other languages and technologies (Java, Python, MySQL, etc.) |
For MySQL it works; CREATE TABLE `test` (
`test` ENUM('a') NOT NULL
); Some extra info;
@stof the use case is we currently only support 1 option of the enum (implementation-wise that is), as soon as other options are implemented we want to expand the enum with the newly implemented options, i.e. make them available for configuration. |
In case this feature request is accepted, there is a pull request to implement it: #15433. |
I see no real reason (apart from ideology) to prevent single element enums. This seems like a pretty standard way to be forward-compatible. So no real reason to arbitrarily prevent it IMHO. |
…ereguiluz) This PR was squashed before being merged into the 2.8 branch (closes #15433). Discussion ---------- Allow to define Enum nodes with 1 single element | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15402 | License | MIT | Doc PR | - Commits ------- 68f0818 Allow to define Enum nodes with 1 single element
Hi,
The enum node definition for the symfony config component is great.. but i cant specify only 1 option:
Why is this limited? I.e. an enum with 1 option would still be an enum, imho.
We use some class property for the available values, so we have a single point of entrance where we can comment out an available value, ie;
This way removing the available value 'b' enforces you to refactor the enum node to a scalar node with custom validation (in_array that is), almost like the enum type does ;-)
The text was updated successfully, but these errors were encountered: