cakephp-entity icon indicating copy to clipboard operation
cakephp-entity copied to clipboard

Fixed issue where table alias is used in `FROM` in SQL query

Open stephen1807 opened this issue 6 years ago • 1 comments

Problem:

CakePHP: 2.9.9 PHP: 7.0.12

When Class A extends Table from Entity.ORM and Class B has belongsTo association to Class A, performing SQL query in Class B would result table alias used as table name in SQL query. This is an issue if the belongsTo group name is not the same as associated model name.

E.g.

$belongsTo = [
    'AnotherUser' => [
            'className'  => 'User',
            'foreignKey' => 'another_user_id',
    ]
]

Fix:

Removed assigning alias to name

stephen1807 avatar Jun 25 '18 03:06 stephen1807

Do you mind also fixing the phpunit integration so tests actually run, as well as adding a test for this?

josegonzalez avatar Jun 25 '18 12:06 josegonzalez