Open damiankosiorowski opened 6 years ago
Create a table with name starts with "id" in which one of the fields will be joined by a foreign key with predefined User (ActiveRecord) - i use the advanced template. In Gii, generate a model for table user.
User
user
My test DB dump (PostgreSQL!): gii-issue.zip Alternatively, the migration file to a clean DB: m130524_201442_init.zip
It is not expected to trim "id" from the function name. In the below example it should by:
/** * @return \yii\db\ActiveQuery */ public function getIdeas() { return $this->hasMany(Idea::className(), ['created_by' => 'id']); }
Ex. function of the relationship:
/** * @return \yii\db\ActiveQuery */ public function getEas() { return $this->hasMany(Idea::className(), ['created_by' => 'id']); }
Probably the responsible code: https://github.com/yiisoft/yii2-gii/blob/01883a8df21d0eedd64a5459454d6fc5e2d54bbb/src/generators/model/Generator.php#L690
Please post DB schema to reproduce the issue. Thanks.
DB dump and alternatively migration file have been added in root comment.
What steps will reproduce the problem?
Create a table with name starts with "id" in which one of the fields will be joined by a foreign key with predefined
User
(ActiveRecord) - i use the advanced template. In Gii, generate a model for tableuser
.My test DB dump (PostgreSQL!): gii-issue.zip Alternatively, the migration file to a clean DB: m130524_201442_init.zip
What's expected?
It is not expected to trim "id" from the function name. In the below example it should by:
What do you get instead?
Ex. function of the relationship:
Additional info
Probably the responsible code: https://github.com/yiisoft/yii2-gii/blob/01883a8df21d0eedd64a5459454d6fc5e2d54bbb/src/generators/model/Generator.php#L690