azuredatastudio icon indicating copy to clipboard operation
azuredatastudio copied to clipboard

Setting primary key in table designer/primary key tab does not uncheck Allow Nulls option

Open nielsvdc opened this issue 2 years ago • 2 comments

  • Azure Data Studio Version: 1.38
  • OS Version: Windows 11 (10.0.22000)

Steps to Reproduce:

  1. Open the table designer for a MSSQL table and go to the Primary Key tab.

  2. Add one or more columns that have the "Allow Nulls" option checked.

  3. In the Issues pane a message is shown "Columns in primary key cannot be nullable".

  4. Go to the Columns tab and you will see the "Primary Key" option checked and the "Allow Nulls" option checked but disabled.

  5. Another way is does work is to go to the Columns tab.

  6. Click the "Primary Key" option for a column that has the "Allow Nulls" option checked.

  7. You will see that the "Allow Nulls" is automatically unchecked.

I see different behavior of methods that should work in the same way.

image

Does this issue occur when all extensions are disabled?: Yes/No

nielsvdc avatar Aug 03 '22 10:08 nielsvdc

I believe this was by design when we implemented this part. The current implementation is that when a user adds a column from the Primary Key tab, we are adding the first column of the table as a "placeholder", later a user can change it to the actual column (or another placeholder) the user wants so it might not make sense to automatically mark the placeholder as NOT NULL. There's no good way of identifying the "commit point" of this operation, while in Columns tab it's clear that which exact column is picked. That's why we do auto NOT NULL in Columns tab but not Primary Key tab.

thoughts? @alanrenmsft

caohai avatar Aug 04 '22 18:08 caohai

@caohai let's set the allowNulls to false if a column is added to primary key in the primary key tab, otherwise it is not intuitive for user to correct it.

alanrenmsft avatar Aug 08 '22 18:08 alanrenmsft