21293 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 858 Views |
-
Enum and numbers

23 July 2011 at 1:24am Last edited: 23 July 2011 1:25am
I'm currently building a dropdown list based on the enum:
'Duration' => "Enum('1,2,3,4,5,6,7,8,9,10',5)"It seems to be working fine on the form using:
$this->dbObject('Duration')->enumValues())The only weird behavior, is every time I do a dev/build, it attempts to redefine the field with:
Field PromotionBanner.Duration: changed to enum('1','2','3','4','5','6','7','8','9','10') character set utf8 collate utf8_general_ci default '5' (from enum('1','2','3','4','5','6','7','8','9','10') character set utf8 collate utf8_general_ci default 5)I've also tried:
'Duration' => "Enum('1,2,3,4,5,6,7,8,9,10','5')"
and got the same behavior.Edit: taking out the default value completely results in:
Field PromotionBanner.Duration: changed to enum('1','2','3','4','5','6','7','8','9','10') character set utf8 collate utf8_general_ci default '1' (from enum('1','2','3','4','5','6','7','8','9','10') character set utf8 collate utf8_general_ci default 1)every dev/build also.
It seems mysql is interpreting the default as an integer instead of a string upon assignment.
-
Re: Enum and numbers

23 July 2011 at 4:06am
besides from it being weird that it is redefined every time to exactly the same format as it was before - is it harming your site/content at all?
I've also seen this happen with enum fields, but it didn't damage or change anything, as I recall. Probably some gltch in SilverStripe checking the enum fieldformat?
-
Re: Enum and numbers

31 August 2011 at 5:44am
Same thing here. Doesn't seem to harm content, but I'm OCD about code and process neatness and it's driving me crazy.
But seriously, any unnecessary writes to DB structure should be avoided, as a matter of principle, so I would really like to figure this out.
-
Re: Enum and numbers

31 August 2011 at 7:57am
@johnmblack: I got it as far as sapphire/core/model/Database.php, somewhere around line 321:
if(substr($spec, 0, 4) == "enum") { ...
That's where some special enum handling seems to be going on, checking if the field has changed before altering the table. So maybe you want to take it from there?
-
Re: Enum and numbers

19 November 2011 at 10:17am
I couldn't find a fix either, so I changed mine to: "one, two, three"
| 858 Views | ||
|
Page:
1
|
Go to Top |



