[Table Designer] Add apis to support computed column (#1495)

This commit is contained in:
Hai Cao
2022-05-23 15:41:07 -07:00
committed by GitHub
parent 62d3cdc99a
commit bc1b60fa87
7 changed files with 266 additions and 1 deletions

View File

@@ -9061,6 +9061,78 @@ namespace Microsoft.SqlTools.ServiceLayer
}
}
public static string TableColumnComputedGroupTitle
{
get
{
return Keys.GetString(Keys.TableColumnComputedGroupTitle);
}
}
public static string TableColumnIsComputedTitle
{
get
{
return Keys.GetString(Keys.TableColumnIsComputedTitle);
}
}
public static string TableColumnIsComputedDescription
{
get
{
return Keys.GetString(Keys.TableColumnIsComputedDescription);
}
}
public static string TableColumnComputedFormulaTitle
{
get
{
return Keys.GetString(Keys.TableColumnComputedFormulaTitle);
}
}
public static string TableColumnComputedFormulaDescription
{
get
{
return Keys.GetString(Keys.TableColumnComputedFormulaDescription);
}
}
public static string TableColumnIsComputedPersistedTitle
{
get
{
return Keys.GetString(Keys.TableColumnIsComputedPersistedTitle);
}
}
public static string TableColumnIsComputedPersistedDescription
{
get
{
return Keys.GetString(Keys.TableColumnIsComputedPersistedDescription);
}
}
public static string TableColumnIsComputedPersistedNullableTitle
{
get
{
return Keys.GetString(Keys.TableColumnIsComputedPersistedNullableTitle);
}
}
public static string TableColumnIsComputedPersistedNullableDescription
{
get
{
return Keys.GetString(Keys.TableColumnIsComputedPersistedNullableDescription);
}
}
public static string ConnectionServiceListDbErrorNotConnected(string uri)
{
return Keys.GetString(Keys.ConnectionServiceListDbErrorNotConnected, uri);
@@ -12952,6 +13024,33 @@ namespace Microsoft.SqlTools.ServiceLayer
public const string AddNewClauseLabel = "AddNewClauseLabel";
public const string TableColumnComputedGroupTitle = "TableColumnComputedGroupTitle";
public const string TableColumnIsComputedTitle = "TableColumnIsComputedTitle";
public const string TableColumnIsComputedDescription = "TableColumnIsComputedDescription";
public const string TableColumnComputedFormulaTitle = "TableColumnComputedFormulaTitle";
public const string TableColumnComputedFormulaDescription = "TableColumnComputedFormulaDescription";
public const string TableColumnIsComputedPersistedTitle = "TableColumnIsComputedPersistedTitle";
public const string TableColumnIsComputedPersistedDescription = "TableColumnIsComputedPersistedDescription";
public const string TableColumnIsComputedPersistedNullableTitle = "TableColumnIsComputedPersistedNullableTitle";
public const string TableColumnIsComputedPersistedNullableDescription = "TableColumnIsComputedPersistedNullableDescription";
private Keys()
{ }

View File

@@ -4947,4 +4947,40 @@ The Query Processor estimates that implementing the following index could improv
<value>New Clause</value>
<comment></comment>
</data>
<data name="TableColumnComputedGroupTitle" xml:space="preserve">
<value>Computed Column Specifications</value>
<comment></comment>
</data>
<data name="TableColumnIsComputedTitle" xml:space="preserve">
<value>Is Computed</value>
<comment></comment>
</data>
<data name="TableColumnIsComputedDescription" xml:space="preserve">
<value>Specifies whether the column is a computed column</value>
<comment></comment>
</data>
<data name="TableColumnComputedFormulaTitle" xml:space="preserve">
<value>Formula</value>
<comment></comment>
</data>
<data name="TableColumnComputedFormulaDescription" xml:space="preserve">
<value>Formula that the column uses if it is a computed column</value>
<comment></comment>
</data>
<data name="TableColumnIsComputedPersistedTitle" xml:space="preserve">
<value>Is Persisted</value>
<comment></comment>
</data>
<data name="TableColumnIsComputedPersistedDescription" xml:space="preserve">
<value>Whether the computed column is saved with the data source</value>
<comment></comment>
</data>
<data name="TableColumnIsComputedPersistedNullableTitle" xml:space="preserve">
<value>Is Persisted Nullable</value>
<comment></comment>
</data>
<data name="TableColumnIsComputedPersistedNullableDescription" xml:space="preserve">
<value>Whether the computed column can have a NULL value (NOT NULL can only be specified if the column is persisted)</value>
<comment></comment>
</data>
</root>

View File

@@ -2311,4 +2311,13 @@ TableDesignerNewHistoryTableTitle = New History Table Name
TableColumnDefaultConstraintNamePropertyDescription = Specifies the default constraint name.
TableColumnDefaultConstraintNamePropertyTitle = Default Constraint Name
AddNewEdgeConstraintLabel = New Edge Constraint
AddNewClauseLabel = New Clause
AddNewClauseLabel = New Clause
TableColumnComputedGroupTitle = Computed Column Specifications
TableColumnIsComputedTitle = Is Computed
TableColumnIsComputedDescription = Specifies whether the column is a computed column
TableColumnComputedFormulaTitle = Formula
TableColumnComputedFormulaDescription = Formula that the column uses if it is a computed column
TableColumnIsComputedPersistedTitle = Is Persisted
TableColumnIsComputedPersistedDescription = Whether the computed column is saved with the data source
TableColumnIsComputedPersistedNullableTitle = Is Persisted Nullable
TableColumnIsComputedPersistedNullableDescription = Whether the computed column can have a NULL value (NOT NULL can only be specified if the column is persisted)

View File

@@ -6023,6 +6023,51 @@ The Query Processor estimates that implementing the following index could improv
<target state="new">Parallel Execution</target>
<note>tooltip text for node parallelism overlay</note>
</trans-unit>
<trans-unit id="TableColumnComputedGroupTitle">
<source>Computed Column Specifications</source>
<target state="new">Computed Column Specifications</target>
<note></note>
</trans-unit>
<trans-unit id="TableColumnIsComputedTitle">
<source>Is Computed</source>
<target state="new">Is Computed</target>
<note></note>
</trans-unit>
<trans-unit id="TableColumnIsComputedDescription">
<source>Specifies whether the column is a computed column</source>
<target state="new">Specifies whether the column is a computed column</target>
<note></note>
</trans-unit>
<trans-unit id="TableColumnIsComputedPersistedTitle">
<source>Is Persisted</source>
<target state="new">Is Persisted</target>
<note></note>
</trans-unit>
<trans-unit id="TableColumnIsComputedPersistedDescription">
<source>Whether the computed column is saved with the data source</source>
<target state="new">Whether the computed column is saved with the data source</target>
<note></note>
</trans-unit>
<trans-unit id="TableColumnIsComputedPersistedNullableTitle">
<source>Is Persisted Nullable</source>
<target state="new">Is Persisted Nullable</target>
<note></note>
</trans-unit>
<trans-unit id="TableColumnIsComputedPersistedNullableDescription">
<source>Whether the computed column can have a NULL value (NOT NULL can only be specified if the column is persisted)</source>
<target state="new">Whether the computed column can have a NULL value (NOT NULL can only be specified if the column is persisted)</target>
<note></note>
</trans-unit>
<trans-unit id="TableColumnComputedFormulaDescription">
<source>Formula that the column uses if it is a computed column</source>
<target state="new">Formula that the column uses if it is a computed column</target>
<note></note>
</trans-unit>
<trans-unit id="TableColumnComputedFormulaTitle">
<source>Formula</source>
<target state="new">Formula</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

View File

@@ -43,6 +43,10 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
public const string IsIdentity = "isIdentity";
public const string IdentityIncrement = "identityIncrement";
public const string IdentitySeed = "identitySeed";
public const string IsComputed = "isComputed";
public const string ComputedFormula = "computedFormula";
public const string IsComputedPersisted = "isComputedPersisted";
public const string IsComputedPersistedNullable = "isComputedPersistedNullable";
public const string CanBeDeleted = "canBeDeleted";
public const string GeneratedAlwaysAs = "generatedAlwaysAs";
public const string IsHidden = "isHidden";

View File

@@ -31,6 +31,14 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
public InputBoxProperties IdentityIncrement { get; set; } = new InputBoxProperties();
public CheckBoxProperties IsComputed { get; set; } = new CheckBoxProperties();
public InputBoxProperties ComputedFormula { get; set; } = new InputBoxProperties();
public CheckBoxProperties IsComputedPersisted { get; set; } = new CheckBoxProperties();
public CheckBoxProperties IsComputedPersistedNullable { get; set; } = new CheckBoxProperties();
public DropdownProperties GeneratedAlwaysAs { get; set; } = new DropdownProperties();
public CheckBoxProperties IsHidden { get; set; } = new CheckBoxProperties();

View File

@@ -507,6 +507,18 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
case TableColumnPropertyNames.DefaultConstraintName:
column.DefaultConstraintName = GetStringValue(newValue);
break;
case TableColumnPropertyNames.IsComputed:
column.IsComputed = GetBooleanValue(newValue);
break;
case TableColumnPropertyNames.ComputedFormula:
column.ComputedFormula = GetStringValue(newValue);
break;
case TableColumnPropertyNames.IsComputedPersisted:
column.IsComputedPersisted = GetBooleanValue(newValue);
break;
case TableColumnPropertyNames.IsComputedPersistedNullable:
column.IsComputedPersistedNullable = GetBooleanValue(newValue);
break;
default:
break;
}
@@ -816,6 +828,14 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
columnViewModel.IdentityIncrement.Enabled = column.CanEditIdentityValues;
columnViewModel.IdentityIncrement.Value = column.IdentityIncrement?.ToString();
columnViewModel.CanBeDeleted = column.CanBeDeleted;
columnViewModel.IsComputed.Enabled = column.CanEditIsComputed;
columnViewModel.IsComputed.Checked = column.IsComputed;
columnViewModel.ComputedFormula.Enabled = column.CanEditComputedFormula;
columnViewModel.ComputedFormula.Value = column.ComputedFormula;
columnViewModel.IsComputedPersisted.Enabled = column.CanEditIsComputedPersisted;
columnViewModel.IsComputedPersisted.Checked = column.IsComputedPersisted == true;
columnViewModel.IsComputedPersistedNullable.Enabled = column.CanEditIsComputedPersistedNullable;
columnViewModel.IsComputedPersistedNullable.Checked = column.IsComputedPersistedNullable == true;
columnViewModel.GeneratedAlwaysAs.Value = ColumnGeneratedAlwaysAsTypeUtil.Instance.GetName(column.GeneratedAlwaysAs);
columnViewModel.GeneratedAlwaysAs.Values = ColumnGeneratedAlwaysAsTypeUtil.Instance.DisplayNames;
columnViewModel.GeneratedAlwaysAs.Enabled = column.CanEditGeneratedAlwaysAs;
@@ -1004,6 +1024,50 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
{
Title = SR.TableColumnDefaultConstraintNamePropertyTitle
}
},
new DesignerDataPropertyInfo()
{
PropertyName = TableColumnPropertyNames.IsComputed,
Description = SR.TableColumnIsComputedDescription,
Group = SR.TableColumnComputedGroupTitle,
ComponentType = DesignerComponentType.Checkbox,
ComponentProperties = new CheckBoxProperties()
{
Title = SR.TableColumnIsComputedTitle
}
},
new DesignerDataPropertyInfo()
{
PropertyName = TableColumnPropertyNames.ComputedFormula,
Description = SR.TableColumnComputedFormulaDescription,
Group = SR.TableColumnComputedGroupTitle,
ComponentType = DesignerComponentType.Input,
ComponentProperties = new InputBoxProperties()
{
Title = SR.TableColumnComputedFormulaTitle
}
},
new DesignerDataPropertyInfo()
{
PropertyName = TableColumnPropertyNames.IsComputedPersisted,
Description = SR.TableColumnIsComputedPersistedDescription,
Group = SR.TableColumnComputedGroupTitle,
ComponentType = DesignerComponentType.Checkbox,
ComponentProperties = new CheckBoxProperties()
{
Title = SR.TableColumnIsComputedPersistedTitle
}
},
new DesignerDataPropertyInfo()
{
PropertyName = TableColumnPropertyNames.IsComputedPersistedNullable,
Description = SR.TableColumnIsComputedPersistedNullableDescription,
Group = SR.TableColumnComputedGroupTitle,
ComponentType = DesignerComponentType.Checkbox,
ComponentProperties = new CheckBoxProperties()
{
Title = SR.TableColumnIsComputedPersistedNullableTitle
}
}
});
view.ColumnTableOptions.CanAddRows = true;