phalcon / phalcon-devtools

Phalcon Developer Tools
https://docs.phalcon.io/latest/en/devtools
Other
1.33k stars 631 forks source link

generate entity from webtools does not work #1415

Closed zak-wojtek77 closed 3 years ago

zak-wojtek77 commented 4 years ago

Expected and Actual Behavior

Generate entity from webtools does not work. After click button "Generate" nothing do. Also I don't see any errors on screen.

Phalcon WebTools

Jeckerson commented 4 years ago

Can you specify what exactly entities or which part of WebTools?

zak-wojtek77 commented 4 years ago

For every entity does not work.

Jeckerson commented 4 years ago

image

Do you have SQL error message?

zak-wojtek77 commented 4 years ago

I have not any SQL error. I have upgrade devtools to v4.0.1 but still the same problem.

I click: Models -> Generate and next click button "Generate": Przechwycenie obrazu ekranu_2020-01-21_09-07-18 Przechwycenie obrazu ekranu_2020-01-21_09-07-30

Jeckerson commented 4 years ago

What fields and checkboxes do you select?

zak-wojtek77 commented 4 years ago

Exactly how is on the screen.

tallande commented 4 years ago

Exactly de same trouble, with:

mocallu commented 4 years ago

I had the same problem. I solved removing the options from config's database array.

return new Config([
    'database' => [
        'adapter'    => 'Mysql',
        'host'       => getenv('MYSQL_HOST') ?: '',
        'username'   => getenv('MYSQL_USER') ?: '',
        'password'   => getenv('MYSQL_PASSWORD') ?: '',
        'dbname'     => getenv('MYSQL_DATABASE') ?: '',
        'charset'    => 'utf8',
        // 'options' => [
        //     PDO::ATTR_EMULATE_PREPARES => false,
        //     PDO::ATTR_STRINGIFY_FETCHES => false,
        // ]
    ],
    'application' => [
        'modelsDir'      => '/models/',
        'controllersDir' => '/controllers/',
        'migrationsDir'  => '/migrations/',
        'baseUri'        => '/',
    ]
]);

After create the models, return with the options.

It's happening because before adapter instance, there are some lines creating a condition that removes all database config in $configArray overriding just with options.

if (isset($configArray['options'])) {
    $configArray = $configArray['options'];
}
/** @var AbstractPdo $db */
$db = new $adapterName($configArray);

It's a little weird, I tried to understand why, but I can't.

That's the file and line: https://github.com/phalcon/phalcon-devtools/blob/f96c3062969af1cdec7ba97606b99dba6062b47e/src/Builder/Component/Model.php#L142

BeMySlaveDarlin commented 3 years ago
if (isset($configArray['options'])) {
    $configArray = $configArray['options'];
}

It was added in #1432 due to 'fix' PdoFactory behavior. Unnecessary and breaking addition. Fixed in #1486

Jeckerson commented 3 years ago

Will be released in next version.