TablePlus icon indicating copy to clipboard operation
TablePlus copied to clipboard

Foreign key update/delete appear as numbers instead of values

Open kokoshneta opened this issue 2 years ago • 1 comments

  1. Which driver are you using and version of it (Ex: PostgreSQL 10.0): SQL Server 2019 (possibly others, don’t know)

  2. Which TablePlus build number are you using (the number on the welcome screen, Ex: build 81): 5.3.6 (496)

  3. The steps to reproduce this issue: Open an existing database with foreign keys and show the foreign key definition


 

Incorrect value displayed

When showing the definition of existing foreign keys, the “On Update” and “On Delete” dropdowns area always seem to have a numeric value preselected (seemingly 0 for SET NULL and 1 for CASCADE – haven’t tried with other values):

Incorrect foreign key definition

If you change it to one of the ‘normal’ values, hit “OK” and then open the FK definition again, it looks correct:

Correct foreign key definition

Note that the previous value 1 no longer even appears as a possible option in the dropdown menu.

If you change both values and save the change to the database, TablePlus refreshes the table, and the numeric values immediately reappear.

Incorrect value persisted

If you change only one of the two options, the other one keeps its numeric value, even in the query TablePlus generates to persist the changes to the table. After setting the “On Delete” value to CASCADE in the screenshot above, this is the query TablePlus will run when I hit Cmd + S to save:

ALTER TABLE [dbo].[obj_data] DROP CONSTRAINT FK__obj_data__eln__4891720A;

ALTER TABLE [dbo].[obj_data] ADD FOREIGN KEY ([eln]) REFERENCES [dbo].[products] ([eln]) ON UPDATE 1 ON DELETE CASCADE;

This, of course, cause an error:

Msg: 102, Line 1, State: 1, Level: 15
Incorrect syntax near '1'.
All changes were reverted (DDL statements can't be reverted).

kokoshneta avatar May 27 '23 11:05 kokoshneta

Any update on this? Still an issue.

Seems like it should be something quite simple, like a missing conversion of an integer constant to its textual representation somewhere.

kokoshneta avatar Nov 29 '23 10:11 kokoshneta