mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-19 17:23:55 -05:00
A few table designer improvements (#1456)
* add AdvancedType related contract & lib call * use type list from col * add description support to all view models * remove desc for edge constraint * bump DacFx to 160.6093.0-preview * nit
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
<PackageReference Update="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" Version="1.1.1" />
|
||||
<PackageReference Update="Microsoft.Data.SqlClient" Version="3.0.0"/>
|
||||
<PackageReference Update="Microsoft.SqlServer.SqlManagementObjects" Version="161.46367.54" />
|
||||
<PackageReference Update="Microsoft.SqlServer.DACFx" Version="160.6057.0-preview" GeneratePathProperty="true" />
|
||||
<PackageReference Update="Microsoft.SqlServer.DACFx" Version="160.6093.0-preview" GeneratePathProperty="true" />
|
||||
<PackageReference Update="Microsoft.Azure.Kusto.Data" Version="9.0.4" />
|
||||
<PackageReference Update="Microsoft.Azure.Kusto.Language" Version="9.0.4"/>
|
||||
<PackageReference Update="Microsoft.SqlServer.Assessment" Version="[1.0.305]" />
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
public const string IsMemoryOptimized = "isMemoryOptimized";
|
||||
public const string Durability = "durability";
|
||||
public const string PrimaryKeyName = "primaryKeyName";
|
||||
public const string PrimaryKeyDescription = "primaryKeyDescription";
|
||||
public const string PrimaryKeyIsClustered = "primaryKeyIsClustered";
|
||||
public const string PrimaryKeyColumns = "primaryKeyColumns";
|
||||
}
|
||||
@@ -30,6 +31,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
public static class TableColumnPropertyNames
|
||||
{
|
||||
public const string Name = "name";
|
||||
public const string Description = "description";
|
||||
public const string AdvancedType = "advancedType";
|
||||
public const string Type = "type";
|
||||
public const string DefaultValue = "defaultValue";
|
||||
public const string Length = "length";
|
||||
@@ -49,6 +52,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
public static class ForeignKeyPropertyNames
|
||||
{
|
||||
public const string Name = "name";
|
||||
public const string Description = "description";
|
||||
public const string Enabled = "enabled";
|
||||
public const string OnDeleteAction = "onDeleteAction";
|
||||
public const string OnUpdateAction = "onUpdateAction";
|
||||
@@ -60,6 +64,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
public static class CheckConstraintPropertyNames
|
||||
{
|
||||
public const string Name = "name";
|
||||
public const string Description = "description";
|
||||
public const string Enabled = "enabled";
|
||||
public const string Expression = "expression";
|
||||
}
|
||||
@@ -73,6 +78,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
public static class IndexPropertyNames
|
||||
{
|
||||
public const string Name = "name";
|
||||
public const string Description = "description";
|
||||
public const string Enabled = "enabled";
|
||||
public const string IsUnique = "isUnique";
|
||||
public const string IsClustered = "isClustered";
|
||||
|
||||
@@ -11,5 +11,6 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
public abstract class ObjectViewModelBase
|
||||
{
|
||||
public InputBoxProperties Name { get; set; } = new InputBoxProperties();
|
||||
public InputBoxProperties Description { get; set; } = new InputBoxProperties();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
/// </summary>
|
||||
public class TableColumnViewModel : ObjectViewModelBase
|
||||
{
|
||||
public DropdownProperties AdvancedType { get; set; } = new DropdownProperties();
|
||||
public DropdownProperties Type { get; set; } = new DropdownProperties();
|
||||
|
||||
public InputBoxProperties Length { get; set; } = new InputBoxProperties();
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
{
|
||||
public DropdownProperties Schema { get; set; } = new DropdownProperties();
|
||||
|
||||
public InputBoxProperties Description { get; set; } = new InputBoxProperties();
|
||||
|
||||
public DropdownProperties GraphTableType { get; set; } = new DropdownProperties();
|
||||
|
||||
public CheckBoxProperties IsMemoryOptimized { get; set; } = new CheckBoxProperties();
|
||||
@@ -29,6 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
public InputBoxProperties NewHistoryTableName { get; set; } = new InputBoxProperties();
|
||||
|
||||
public InputBoxProperties PrimaryKeyName { get; set; } = new InputBoxProperties();
|
||||
public InputBoxProperties PrimaryKeyDescription { get; set; } = new InputBoxProperties();
|
||||
|
||||
public CheckBoxProperties PrimaryKeyIsClustered { get; set; } = new CheckBoxProperties();
|
||||
|
||||
|
||||
@@ -409,6 +409,12 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
table.PrimaryKey.Name = GetStringValue(newValue);
|
||||
}
|
||||
break;
|
||||
case TablePropertyNames.PrimaryKeyDescription:
|
||||
if (table.PrimaryKey != null)
|
||||
{
|
||||
table.PrimaryKey.Description = GetStringValue(newValue);
|
||||
}
|
||||
break;
|
||||
case TablePropertyNames.PrimaryKeyIsClustered:
|
||||
if (table.PrimaryKey != null)
|
||||
{
|
||||
@@ -463,6 +469,12 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
case TableColumnPropertyNames.Type:
|
||||
column.DataType = GetStringValue(newValue);
|
||||
break;
|
||||
case TableColumnPropertyNames.AdvancedType:
|
||||
column.AdvancedDataType = GetStringValue(newValue);
|
||||
break;
|
||||
case TableColumnPropertyNames.Description:
|
||||
column.Description = GetStringValue(newValue);
|
||||
break;
|
||||
case TableColumnPropertyNames.GeneratedAlwaysAs:
|
||||
column.GeneratedAlwaysAs = ColumnGeneratedAlwaysAsTypeUtil.Instance.GetValue(GetStringValue(newValue));
|
||||
break;
|
||||
@@ -483,6 +495,9 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
case CheckConstraintPropertyNames.Name:
|
||||
checkConstraint.Name = GetStringValue(newValue);
|
||||
break;
|
||||
case CheckConstraintPropertyNames.Description:
|
||||
checkConstraint.Description = GetStringValue(newValue);
|
||||
break;
|
||||
case CheckConstraintPropertyNames.Enabled:
|
||||
checkConstraint.Enabled = GetBooleanValue(newValue);
|
||||
break;
|
||||
@@ -506,6 +521,9 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
case ForeignKeyPropertyNames.Name:
|
||||
foreignKey.Name = GetStringValue(newValue);
|
||||
break;
|
||||
case ForeignKeyPropertyNames.Description:
|
||||
foreignKey.Description = GetStringValue(newValue);
|
||||
break;
|
||||
case ForeignKeyPropertyNames.OnDeleteAction:
|
||||
foreignKey.OnDeleteAction = SqlForeignKeyActionUtil.Instance.GetValue(GetStringValue(newValue));
|
||||
break;
|
||||
@@ -535,6 +553,9 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
case IndexPropertyNames.Name:
|
||||
sqlIndex.Name = GetStringValue(newValue);
|
||||
break;
|
||||
case IndexPropertyNames.Description:
|
||||
sqlIndex.Description = GetStringValue(newValue);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -682,6 +703,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
if (primaryKey != null)
|
||||
{
|
||||
tableViewModel.PrimaryKeyName.Value = primaryKey.Name;
|
||||
tableViewModel.PrimaryKeyDescription.Value = primaryKey.Description;
|
||||
tableViewModel.PrimaryKeyDescription.Enabled = primaryKey.CanEditDescription;
|
||||
tableViewModel.PrimaryKeyIsClustered.Checked = primaryKey.IsClustered;
|
||||
foreach (var cs in primaryKey.Columns)
|
||||
{
|
||||
@@ -722,6 +745,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
var columnViewModel = new TableColumnViewModel();
|
||||
columnViewModel.Name.Value = column.Name;
|
||||
columnViewModel.Name.Enabled = column.CanEditName;
|
||||
columnViewModel.Description.Value = column.Description;
|
||||
columnViewModel.Description.Enabled = column.CanEditDescription;
|
||||
columnViewModel.Length.Value = column.Length;
|
||||
columnViewModel.Length.Enabled = column.CanEditLength;
|
||||
columnViewModel.Scale.Value = column.Scale?.ToString();
|
||||
@@ -737,6 +762,9 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
columnViewModel.Type.Value = column.DataType;
|
||||
columnViewModel.Type.Enabled = column.CanEditDataType;
|
||||
columnViewModel.Type.Values = tableDesigner.DataTypes.ToList();
|
||||
columnViewModel.AdvancedType.Value = column.AdvancedDataType;
|
||||
columnViewModel.AdvancedType.Enabled = column.CanEditDataType;
|
||||
columnViewModel.AdvancedType.Values = column.AdvancedDataTypes.ToList();
|
||||
columnViewModel.IsIdentity.Enabled = column.CanEditIsIdentity;
|
||||
columnViewModel.IsIdentity.Checked = column.IsIdentity;
|
||||
columnViewModel.IdentitySeed.Enabled = column.CanEditIdentityValues;
|
||||
@@ -758,6 +786,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
{
|
||||
var foreignKeyViewModel = new ForeignKeyViewModel();
|
||||
foreignKeyViewModel.Name.Value = foreignKey.Name;
|
||||
foreignKeyViewModel.Description.Value = foreignKey.Description;
|
||||
foreignKeyViewModel.Description.Enabled = foreignKey.CanEditDescription;
|
||||
foreignKeyViewModel.Enabled.Checked = foreignKey.Enabled;
|
||||
foreignKeyViewModel.OnDeleteAction.Value = SqlForeignKeyActionUtil.Instance.GetName(foreignKey.OnDeleteAction);
|
||||
foreignKeyViewModel.OnDeleteAction.Values = SqlForeignKeyActionUtil.Instance.DisplayNames;
|
||||
@@ -784,6 +814,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
{
|
||||
var constraint = new CheckConstraintViewModel();
|
||||
constraint.Name.Value = checkConstraint.Name;
|
||||
constraint.Description.Value = checkConstraint.Description;
|
||||
constraint.Description.Enabled = checkConstraint.CanEditDescription;
|
||||
constraint.Expression.Value = checkConstraint.Expression;
|
||||
constraint.Enabled.Checked = checkConstraint.Enabled;
|
||||
tableViewModel.CheckConstraints.Data.Add(constraint);
|
||||
@@ -794,6 +826,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
var indexVM = new IndexViewModel();
|
||||
indexVM.Name.Value = index.Name;
|
||||
indexVM.Name.Enabled = tableInfo.IsNewTable; // renaming an index is not supported, it will cause a new index to be created.
|
||||
indexVM.Description.Value = index.Description;
|
||||
indexVM.Description.Enabled = index.CanEditDescription;
|
||||
indexVM.IsClustered.Checked = index.IsClustered;
|
||||
indexVM.Enabled.Checked = index.Enabled;
|
||||
indexVM.IsUnique.Checked = index.IsUnique;
|
||||
@@ -814,6 +848,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
{
|
||||
var constraintVM = new EdgeConstraintViewModel();
|
||||
constraintVM.Name.Value = constraint.Name;
|
||||
constraintVM.Description.Value = constraint.Description;
|
||||
constraintVM.Description.Enabled = constraint.CanEditDescription;
|
||||
constraintVM.Enabled.Checked = constraint.Enabled;
|
||||
constraintVM.OnDeleteAction.Value = SqlForeignKeyActionUtil.Instance.GetName(constraint.OnDeleteAction);
|
||||
constraintVM.OnDeleteAction.Values = SqlForeignKeyActionUtil.Instance.EdgeConstraintOnDeleteActionNames;
|
||||
|
||||
Reference in New Issue
Block a user