Insert row with foreign key does not allow entry of specific relational ID

RickKukiela's profile image RickKukiela posted 2 years ago in General Permalink

I have a junction table with relationships set up (innodb/mariadb)

I was trying to manually insert a row to this table and the ID of the corresponding record could not be entered because rather than giving me a "text" input box, its a select/drop type field where it populates valid values from the linked table you can select from.

I'm all for the assistance of giving me options, but it will not let me enter the ID of the user I wanted to add the row for (1 in this case, recently deleted by accident and had to be manually added so it's likely at the the /end/ of the dataset in the users table now, and there are thousands of users in this table).

It seems that the options list in this field is limited by something and does not show ALL options. This wouldn't be an issue if you were able to just enter your own value, even if it's not in the "list" of options.

Recommended fix is to either ensure ALL possible values are included in the dropdown, or allow entry in the field with an out-of-bounds value for the provided "list" of options.

Or just remove the feature all together and let SQL report constraint error if something invalid is entered...

ansgar's profile image ansgar posted 2 years ago Permalink

You have some ways to get around that.

The drop-down is limited to display 10000 values, and it is sorted by the first text/varchar column in the foreign table.

  • If the foreign table has less than 10000 rows, you see that read-only drop-down box. You can type a "1" while the drop-down is opened, so it should auto-scroll and auto-select the first item beginning with a "1". (which is probably the wrong one, as a "100" will probably be sorted before the "1")
  • If the connected table has 10000 rows or more, the editor is not a drop-down but a simple textbox where you can type anything.
  • I'm aware both two ways so far are not helpful in your situation, but they help to understand how this works. 😉
  • In any case, you can paste a "1" in the cell without activating the editor (just focus the cell)
  • In case you want to disable the foreign key drop-down for all times, you can do that in Tools > Preferences > Data editors. See screenshot below.

Description

Please login to leave a reply, or register at first.