cycle/orm

๐Ÿ› FK id Column case mismatch

gam6itko opened this issue ยท 0 comments

No duplicates ๐Ÿฅฒ.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

We have classes below

class AClass {

   #[Cycle\Column(type: 'integer')]
   private int $userId;
}
class BClass {
    #[Cycle\Relation\BelongsTo(target: User::class)]
    private Exchanger $user;
}
class User {
     #[Cycle\Column(type: 'primary')]
     private ?int $id = null;
   
    // properties here
}

When I make requests like this. In the $aList the members have a userId property, and in the $bList there is a user_id property.

 $aList = $this->getOrm()->getRepository(AClass::class)
            ->select()
            ->fetchData();

// $alist = [ ['userId' => 1] ]
            
 $bList = $this->getOrm()->getRepository(BClass::class)
            ->select()
            ->fetchData();
// $bList = [ ['user_id' => 1, 'user' => ['id' => 1, 'foo' => 'bar']] ]

Is it possible to do something with the #[Cycle\Column(type: 'integer')] to fetch columns in different cases in queries?

Version

PHP 8.1
cycle/orm  2.2.1