simov / express-admin

MySQL, MariaDB, PostgreSQL, SQLite admin for Node.js
MIT License
1.17k stars 222 forks source link

Error creating entry with many to many relationship #145

Open hybridsimone opened 6 years ago

hybridsimone commented 6 years ago

Hello, I have the following many to many relationship in my code:

{
                "name": "newsCategory",
                "verbose": "Kategorie",
                "control": {
                    "select": true,
                    "multiple": true
                },
                "manyToMany": {
                  "link": {
                      "table": "newsCategory",
                      "parentPk": "News_ID",
                      "childPk": "Category_ID"
                  },
                  "ref": {
                      "table": "category",
                      "pk": "ID",
                      "columns": [
                          "Name"
                      ]
                  }
                },
                "type": "varchar(255)",
                "allowNull": false,
                "listview": {
                    "show": true
                },
                "editview": {
                    "show": true
              }
}

but when I try to add a new 'News' entry, I get the error: ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: Incorrect integer value: '' for column 'News_ID' at row 1.

The entry still gets saved but not the 'newsCategory'. When I get back to edit it again I can choses categories and also save them without error. It seems like there is a problem creating an entry and simultaneously using its (auto generated) ID as a foreign key...

Any ideas?