JaquelineBrandao / yii

Automatically exported from code.google.com/p/yii
0 stars 0 forks source link

about enum datatype of crud #656

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. crud command get the 0 size and 0 maxlength input field of mysql .enum
datatype.

Original issue reported on code.google.com by eMule.maya@gmail.com on 30 Oct 2009 at 7:52

GoogleCodeExporter commented 9 years ago

Original comment by qiang.xue on 7 Dec 2009 at 4:27

GoogleCodeExporter commented 9 years ago
@Sebastián: could you take care of this? To be honest, I don't know how to 
deal with
this. I think we should treat enum as string type. But what should be the max 
size?

Original comment by qiang.xue on 5 Jan 2010 at 2:10

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
["test"]=>  object(CMysqlColumnSchema)#20 (13) { ["name"]=>  string(4) "test"
["rawName"]=>  string(6) "`test`" ["allowNull"]=>  bool(false) ["dbType"]=> 
string(17) "enum('asd','dsa')" ["type"]=>  string(6) "string" 
["defaultValue"]=> 
NULL ["size"]=>  int(0) ["precision"]=>  int(0) ["scale"]=>  int(0)
["isPrimaryKey"]=>  bool(false) ["isForeignKey"]=>  bool(false) 
["_e:private"]=> 
NULL ["_m:private"]=>  NULL }

We can use the dbType (enum 'asd', 'dsa') and extend the
extractLimit method in CMysqlColumnSchema with something like this:

    protected function extractLimit($dbType)
    {
        if ($dbType is enmu){
                     $this->size = 0;
                     foreach($enumPossibilites as $enumOption)
                         $this->size = max($this->size, $enumOption);
                else
                     parent::extractLimit($dbType);
        }

Original comment by sebathi on 5 Jan 2010 at 3:46

GoogleCodeExporter commented 9 years ago
Is it possible to get $enumPossibilites? If so, I agree with this solution.

Original comment by qiang.xue on 5 Jan 2010 at 1:59

GoogleCodeExporter commented 9 years ago
Yes, the $dbType will be as follows - all the line:

enum('asd', 'test', 'veryLongEnum')

Original comment by sebathi on 5 Jan 2010 at 2:05

GoogleCodeExporter commented 9 years ago
Fixed r1664

Original comment by sebathi on 5 Jan 2010 at 2:24

GoogleCodeExporter commented 9 years ago
Migrated to http://github.com/yiisoft/yii/issues/3

Original comment by qiang.xue on 15 Feb 2012 at 6:36

GoogleCodeExporter commented 9 years ago
Migrated to http://github.com/yiisoft/yii/issues/43

Original comment by qiang.xue on 15 Feb 2012 at 6:44