Okay
  Public Ticket #3714216
Foreign Keys Not Working Correctly
Closed

Comments

  • Brandon Yoon started the conversation

    Hello,

    I have a number of SQL tables in my database which use Foreign Keys, which I've created some simple wpDataTables SQL-based tables for (e.g. "SELECT * FROM wp_intcp_text_keys"). If there's no foreign keys, then editing a table works perfectly, and I can update everything using the front-end and in-line editors. However, whenever I select a foreign key (for example, selecting a magazine's ID for the key and displaying the magazine's title), suddenly the plugin's editing features completely stop working for that table. I've done enough testing to know that this only happens with tables containing foreign keys.

    I know that there's no problems with the way my database is set up, because I can add the rows containing foreign keys through phpMyAdmin just fine. And clearly the plugin can READ the information correctly, since it's always displaying the correct publication titles for the queried data. However, instead of having normal buttons (New Entry, Edit, Delete), I get the Edit and Delete buttons completely grayed out, while the New button is non-functional. Sometimes, if I reset the foreign key relation setting (in the column Data setting) to display only the foreign ID and not the foreign title, then I can temporarily get the table to show all 3 buttons properly, and they all work okay frontend-wise. However, when I actually try to add or update rows, then wpDataTables throws an error - by the time I reload the page, the buttons are grayed out again.

    In addition to these issues, I also have trouble saving the table settings when the foreign key column's data display is set to "title" (i.e. not the ID, but the title column). Whenever I try to save the column settings, it causes the whole "configure table" page to blank out, and it just shows me the spinning wheel of death indefinitely. It's okay when I reload the page, and usually the settings seem to be correctly set when I reopen them. But it doesn't fix any of the problems with the new/edit/delete functionality.

    All in all, this is a very frustrating error because I'm 90% sure it just has to do with the React.js frontend, not anything to do with my database infrastructure. I've tested this problem on multiple computers, I've uninstalled and reinstalled the plugin multiple times, but it still does this stuff. I don't think I was having these problems earlier, but they suddenly started at some point and I have no idea why they're occurring. But foreign keys are a pretty essential feature, and the main reason why I got this plugin was because exactly because of this feature to display foreign keys as titles, while editing SQL rows in real time by selecting from a drop-down menu. Any support would be greatly appreciated.