Skip to content
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

type ENUM end SET need extra handle #6

Open
irev opened this issue Sep 28, 2020 · 1 comment
Open

type ENUM end SET need extra handle #6

irev opened this issue Sep 28, 2020 · 1 comment

Comments

@irev
Copy link

irev commented Sep 28, 2020

must add new function to handle enum and set

/**
     * Method _extra_enum_set_handle
     *
     * @param $string $string [explicite description]
     *
     * @return String
     */
public function _extra_enum_set_handle($string = null)
    {
        $find = ['/(^\w+\(?)/', '/(\)$)/'];  // reg 'a(' or ')'
        $replace_type = preg_replace($find, '', $string); /// replace first string of type ex set('es','ea') or enum('1','11')
        return $replace_type;
    }

in function get_function_up_content change to:

if (!isset($match[2])) {
                switch (strtoupper($match[0])) {
                        //type enum need extra handle
                    case 'ENUM':
                        $add_field_str .= "\t\t\t\t'constraint' => [" . $this->_extra_enum_set_handle($column['Type']) . "],\n";
                        break;
                    // Add SET type
                    case 'SET':
                        $add_field_str .= "\t\t\t\t'constraint' => [" . $this->_extra_enum_set_handle($column['Type']) . "],\n";
                        break;
                    default:
                        $add_field_str .= "\t\t\t\t'constraint' => '" . strtoupper($column['Type']) . "'," . "\n";
                        break;
                }
            }

on Line 320
constraint is number

       else{
                /// constraint not number 
                if(is_numeric($match[2])){
                    $add_field_str .= "\t\t\t\t'constraint' => '" . strtoupper($match[2]) . "'," . "\n";
                }
            }

RESULT:

            'field' => array(
                'type' => 'SET',
                'constraint SET' => ['aaa','bbb','ccc','ddd','ffff'],
            ),
irev added a commit to irev/codeigniter-migration-generator that referenced this issue Sep 28, 2020
irev added a commit to irev/codeigniter-migration-generator that referenced this issue Sep 28, 2020
@corvenik-ian
Copy link
Owner

corvenik-ian commented Oct 5, 2020

Thx, I will fix this on this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants