Errors with 1-m associations (mysql+npm project setup)

I created the first project following the instructions for the MySQL DB. Installation via npm was successful, all models recognized, no errors or warnings. I went to the forestadmin app and I see all the tables. But in those tables where there are foreign keys, an error occurs. For example, I have a simple relation one user - many characters, error when trying to view the table characters:

[forest] ���  Unexpected error: Unknown column 'characters.user_uid'
in 'on clause'
{
  "name": "SequelizeDatabaseError",
  "parent": {
    "code": "ER_BAD_FIELD_ERROR",
    "errno": 1054,
    "sqlState": "42S22",
    "sqlMessage": "Unknown column 'characters.user_uid' in 'on clause'",
    "sql": "SELECT count(`characters`.`uid`) AS `count` FROM `characters
` AS `characters` LEFT OUTER JOIN `users` AS `userUid` ON `characters`.`
user_uid` = `userUid`.`uid` LEFT OUTER JOIN `users` AS `userUidUserUid`
ON `characters`.`user_uid` = `userUidUserUid`.`uid`;"

But there is no foreign key ‘user_uid’. Correct foreign key name is ‘userUid’. It looks like it ignores the correct foreign key name and tries to generate it according to the rule tableName+_+primaryKey.

In addition, I see strange extra associations in the table settings: userUidUserUid - I don’t have such a table.

Context

  • Database Dialect: MySQL
  • Database Version: 8.0.19
  • Project Name: mcm

Hello @Partizan_Chg & welcome on our community forum :slight_smile:

Can you share to me the following file models/characters.js from your project?

Kind regards,

Hello :slightly_smiling_face:

characters.tar (4 KB)

For example I also attached my sequelize model declaration (typescript decorator).
DBCharacter.model.tar (3 KB)

Hello @Partizan_Chg,

Can you send us also the definition of both tables users and characters please?

Best regards,
Mia

Hello!

models.tar (6 KB)