{"action":"created","issue":{"url":"https://api.github.com/repos/ADOdb/ADOdb/issues/26","labels_url":"https://api.github.com/repos/ADOdb/ADOdb/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/ADOdb/ADOdb/issues/26/comments","events_url":"https://api.github.com/repos/ADOdb/ADOdb/issues/26/events","html_url":"https://github.com/ADOdb/ADOdb/issues/26","id":36568965,"number":26,"title":"Create table cannot handle ENUM field type","user":{"login":"profhun","id":6312594,"avatar_url":"https://avatars.githubusercontent.com/u/6312594?v=3","gravatar_id":"","url":"https://api.github.com/users/profhun","html_url":"https://github.com/profhun","followers_url":"https://api.github.com/users/profhun/followers","following_url":"https://api.github.com/users/profhun/following{/other_user}","gists_url":"https://api.github.com/users/profhun/gists{/gist_id}","starred_url":"https://api.github.com/users/profhun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/profhun/subscriptions","organizations_url":"https://api.github.com/users/profhun/orgs","repos_url":"https://api.github.com/users/profhun/repos","events_url":"https://api.github.com/users/profhun/events{/privacy}","received_events_url":"https://api.github.com/users/profhun/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-06-26T11:57:33Z","updated_at":"2015-04-20T15:52:05Z","closed_at":null,"body":"in adodb-datadict.inc.php _GenFields and _GetSize functions not handle ENUM options.\r\n\r\nWhen you create a new table, and declare fields like this:\r\nid int(10) unsigned PRIMARY NOT NULL AUTO_INCREMENT,\r\n...\r\nstatus enum('active','inactive') NOT NULL DEFAULT 'active'\r\n\r\n_GenFields functions reparse the SQL, and drop the parts next to enum:\r\nENUM NOT NULL DEFAULT 'active'\r\n\r\nFix workaround:\r\n_GetSize add new parameter: $enumops\r\n/**\r\n\t GENERATE THE SIZE PART OF THE DATATYPE\r\n\t\t$ftype is the actual type\r\n\t\t$ty is the type defined originally in the DDL\r\n*/\r\nfunction _GetSize($ftype, $ty, $fsize, $fprec, $enumops)\r\n{\r\n\tif (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) {\r\n\t\t$ftype .= \"(\".$fsize;\r\n\t\tif (strlen($fprec)) $ftype .= \",\".$fprec;\r\n\t\t$ftype .= ')';\r\n\t}\r\n    //ENUM FIX\r\n    if(strtoupper($ftype) == 'ENUM'){\r\n        $ftype .= \"({$enumops})\";\r\n    }\r\n\treturn $ftype;\r\n}\r\n\r\n_GenFields modify like this: (line 663)\r\n\r\n\t\t\t//-----------------\r\n\t\t\t// Parse attributes\r\n\t\t\tforeach($fld as $attr => $v) {\r\n\r\n\t\t\t\tif ($attr == 2 && is_numeric($v)) $attr = 'SIZE';\r\n                //ENUM FIX\r\n                elseif ($attr == 2 && strtoupper($ftype) == 'ENUM') $attr = 'ENUM';\r\n\t\t\t\telseif (is_numeric($attr) && $attr > 1 && !is_numeric($v)) $attr = strtoupper($v);\r\n\r\n... and place this for the end of the switch (line 700):\r\n    \t\t\t\t// let INDEX keyword create a 'very standard' index on column\r\n    \t\t\t\tcase 'INDEX': $findex = $v; break;\r\n    \t\t\t\tcase 'UNIQUE': $funiqueindex = true; break;\r\n                    //ENUM FIX\r\n                    case 'ENUM': $fenumops = $v; break;\r\n\r\nplace the new extra parameter into _GetSize parameters (line 726)\r\n$ftype = $this->_GetSize($ftype, $ty, $fsize, $fprec, $fenumops);\r\n\r\nAnd all working correctly"},"comment":{"url":"https://api.github.com/repos/ADOdb/ADOdb/issues/comments/94491391","html_url":"https://github.com/ADOdb/ADOdb/issues/26#issuecomment-94491391","issue_url":"https://api.github.com/repos/ADOdb/ADOdb/issues/26","id":94491391,"user":{"login":"dregad","id":449891,"avatar_url":"https://avatars.githubusercontent.com/u/449891?v=3","gravatar_id":"","url":"https://api.github.com/users/dregad","html_url":"https://github.com/dregad","followers_url":"https://api.github.com/users/dregad/followers","following_url":"https://api.github.com/users/dregad/following{/other_user}","gists_url":"https://api.github.com/users/dregad/gists{/gist_id}","starred_url":"https://api.github.com/users/dregad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dregad/subscriptions","organizations_url":"https://api.github.com/users/dregad/orgs","repos_url":"https://api.github.com/users/dregad/repos","events_url":"https://api.github.com/users/dregad/events{/privacy}","received_events_url":"https://api.github.com/users/dregad/received_events","type":"User","site_admin":false},"created_at":"2015-04-20T15:52:05Z","updated_at":"2015-04-20T15:52:05Z","body":"Can you please open a pull request for this ?"}}