Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API review fixes #21324

Merged
merged 3 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ protected virtual void Generate([NotNull] AddColumnOperation operation, [NotNull
.Append("computedColumnSql: ")
.Append(Code.Literal(operation.ComputedColumnSql));

if (operation.ComputedColumnIsStored != null)
if (operation.IsStored != null)
{
builder
.AppendLine(",")
.Append("computedColumnIsStored: ")
.Append(Code.Literal(operation.ComputedColumnIsStored));
.Append("stored: ")
.Append(Code.Literal(operation.IsStored));
}
}
else if (operation.DefaultValue != null)
Expand Down Expand Up @@ -561,12 +561,12 @@ protected virtual void Generate([NotNull] AlterColumnOperation operation, [NotNu
.Append("computedColumnSql: ")
.Append(Code.Literal(operation.ComputedColumnSql));

if (operation.ComputedColumnIsStored != null)
if (operation.IsStored != null)
{
builder
.AppendLine(",")
.Append("computedColumnIsStored: ")
.Append(Code.Literal(operation.ComputedColumnIsStored));
.Append("stored: ")
.Append(Code.Literal(operation.IsStored));
}
}
else if (operation.DefaultValue != null)
Expand Down Expand Up @@ -670,12 +670,12 @@ protected virtual void Generate([NotNull] AlterColumnOperation operation, [NotNu
.Append("oldComputedColumnSql: ")
.Append(Code.Literal(operation.OldColumn.ComputedColumnSql));

if (operation.ComputedColumnIsStored != null)
if (operation.IsStored != null)
{
builder
.AppendLine(",")
.Append("oldComputedColumnIsStored: ")
.Append(Code.Literal(operation.OldColumn.ComputedColumnIsStored));
.Append("oldStored: ")
.Append(Code.Literal(operation.OldColumn.IsStored));
}
}
else if (operation.OldColumn.DefaultValue != null)
Expand Down Expand Up @@ -1177,11 +1177,11 @@ protected virtual void Generate([NotNull] CreateTableOperation operation, [NotNu
.Append(", computedColumnSql: ")
.Append(Code.Literal(column.ComputedColumnSql));

if (column.ComputedColumnIsStored != null)
if (column.IsStored != null)
{
builder
.Append(", computedColumnIsStored: ")
.Append(Code.Literal(column.ComputedColumnIsStored));
.Append(", stored: ")
.Append(Code.Literal(column.IsStored));
}
}
else if (column.DefaultValue != null)
Expand Down
10 changes: 5 additions & 5 deletions src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1414,16 +1414,16 @@ protected virtual void GenerateFluentApiForComputedColumn(
.Append("(")
.Append(Code.UnknownLiteral(sql.Value));

var isStored = annotations
.FirstOrDefault(a => a.Name == RelationalAnnotationNames.ComputedColumnIsStored);
var stored = annotations
.FirstOrDefault(a => a.Name == RelationalAnnotationNames.IsStored);

if (isStored != null)
if (stored != null)
{
stringBuilder
.Append(", ")
.Append(Code.UnknownLiteral(isStored.Value));
.Append(Code.UnknownLiteral(stored.Value));

annotations.Remove(isStored);
annotations.Remove(stored);
}

stringBuilder.Append(")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ private void GenerateProperty(IProperty property, bool useDataAnnotations)
RemoveAnnotation(ref annotations, RelationalAnnotationNames.Comment);
RemoveAnnotation(ref annotations, RelationalAnnotationNames.Collation);
RemoveAnnotation(ref annotations, RelationalAnnotationNames.ComputedColumnSql);
RemoveAnnotation(ref annotations, RelationalAnnotationNames.ComputedColumnIsStored);
RemoveAnnotation(ref annotations, RelationalAnnotationNames.IsStored);
RemoveAnnotation(ref annotations, RelationalAnnotationNames.IsFixedLength);
RemoveAnnotation(ref annotations, RelationalAnnotationNames.TableColumnMappings);
RemoveAnnotation(ref annotations, RelationalAnnotationNames.ViewColumnMappings);
Expand Down Expand Up @@ -761,8 +761,8 @@ private void GenerateProperty(IProperty property, bool useDataAnnotations)
lines.Add(
$".{nameof(RelationalPropertyBuilderExtensions.HasComputedColumnSql)}" +
$"({_code.Literal(property.GetComputedColumnSql())}" +
(property.GetComputedColumnIsStored() is bool computedColumnIsStored
? $", stored: {_code.Literal(computedColumnIsStored)})"
(property.GetIsStored() is bool stored
? $", stored: {_code.Literal(stored)})"
: ")"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ protected virtual PropertyBuilder VisitColumn([NotNull] EntityTypeBuilder builde

if (column.ComputedColumnSql != null)
{
property.HasComputedColumnSql(column.ComputedColumnSql, column.ComputedColumnIsStored);
property.HasComputedColumnSql(column.ComputedColumnSql, column.IsStored);
}

if (column.Comment != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,33 +115,33 @@ public virtual Task RollbackTransactionAsync(CancellationToken cancellationToken
}

/// <inheritdoc />
public virtual void CreateSavepoint(string savepointName)
public virtual void CreateSavepoint(string name)
=> _logger.TransactionIgnoredWarning();

/// <inheritdoc />
public virtual Task CreateSavepointAsync(string savepointName, CancellationToken cancellationToken = default)
public virtual Task CreateSavepointAsync(string name, CancellationToken cancellationToken = default)
{
_logger.TransactionIgnoredWarning();
return Task.CompletedTask;
}

/// <inheritdoc />
public virtual void RollbackToSavepoint(string savepointName)
public virtual void RollbackToSavepoint(string name)
=> _logger.TransactionIgnoredWarning();

/// <inheritdoc />
public virtual Task RollbackToSavepointAsync(string savepointName, CancellationToken cancellationToken = default)
public virtual Task RollbackToSavepointAsync(string name, CancellationToken cancellationToken = default)
{
_logger.TransactionIgnoredWarning();
return Task.CompletedTask;
}

/// <inheritdoc />
public virtual void ReleaseSavepoint(string savepointName)
public virtual void ReleaseSavepoint(string name)
=> _logger.TransactionIgnoredWarning();

/// <inheritdoc />
public virtual Task ReleaseSavepointAsync(string savepointName, CancellationToken cancellationToken = default)
public virtual Task ReleaseSavepointAsync(string name, CancellationToken cancellationToken = default)
{
_logger.TransactionIgnoredWarning();
return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ public static PropertyBuilder HasComputedColumnSql(

if (stored != null)
{
propertyBuilder.Metadata.SetComputedColumnIsStored(stored);
propertyBuilder.Metadata.SetIsStored(stored);
}

return propertyBuilder;
Expand Down Expand Up @@ -552,7 +552,7 @@ public static IConventionPropertyBuilder IsStoredComputedColumn(
return null;
}

propertyBuilder.Metadata.SetComputedColumnIsStored(stored, fromDataAnnotation);
propertyBuilder.Metadata.SetIsStored(stored, fromDataAnnotation);
return propertyBuilder;
}

Expand Down Expand Up @@ -588,7 +588,7 @@ public static bool CanSetIsStoredComputedColumn(
bool? stored,
bool fromDataAnnotation = false)
=> propertyBuilder.CanSetAnnotation(
RelationalAnnotationNames.ComputedColumnIsStored,
RelationalAnnotationNames.IsStored,
stored,
fromDataAnnotation);

Expand Down
22 changes: 11 additions & 11 deletions src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,9 @@ public static string SetComputedColumnSql(
/// Whether the value of the computed column this property is mapped to is stored in the database,
/// or calculated when it is read.
/// </returns>
public static bool? GetComputedColumnIsStored([NotNull] this IProperty property)
public static bool? GetIsStored([NotNull] this IProperty property)
{
var annotation = property.FindAnnotation(RelationalAnnotationNames.ComputedColumnIsStored);
var annotation = property.FindAnnotation(RelationalAnnotationNames.IsStored);
return annotation != null ? (bool?)annotation.Value : null;
}

Expand All @@ -719,12 +719,12 @@ public static string SetComputedColumnSql(
/// Whether the value of the computed column this property is mapped to is stored in the database,
/// or calculated when it is read.
/// </returns>
public static bool? GetComputedColumnIsStored(
public static bool? GetIsStored(
[NotNull] this IProperty property,
[NotNull] string tableName,
[CanBeNull] string schema)
{
var annotation = property.FindAnnotation(RelationalAnnotationNames.ComputedColumnIsStored);
var annotation = property.FindAnnotation(RelationalAnnotationNames.IsStored);
if (annotation != null)
{
return (bool?)annotation.Value;
Expand All @@ -733,7 +733,7 @@ public static string SetComputedColumnSql(
var sharedTableRootProperty = property.FindSharedTableRootProperty(tableName, schema);
if (sharedTableRootProperty != null)
{
return GetComputedColumnIsStored(sharedTableRootProperty, tableName, schema);
return GetIsStored(sharedTableRootProperty, tableName, schema);
}

return null;
Expand All @@ -745,9 +745,9 @@ public static string SetComputedColumnSql(
/// </summary>
/// <param name="property"> The property. </param>
/// <param name="value"> The value to set. </param>
public static void SetComputedColumnIsStored([NotNull] this IMutableProperty property, bool? value)
public static void SetIsStored([NotNull] this IMutableProperty property, bool? value)
=> property.SetOrRemoveAnnotation(
RelationalAnnotationNames.ComputedColumnIsStored,
RelationalAnnotationNames.IsStored,
value);

/// <summary>
Expand All @@ -758,10 +758,10 @@ public static void SetComputedColumnIsStored([NotNull] this IMutableProperty pro
/// <param name="value"> The value to set. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> The configured value. </returns>
public static bool? SetComputedColumnIsStored(
public static bool? SetIsStored(
[NotNull] this IConventionProperty property, bool? value, bool fromDataAnnotation = false)
{
property.SetOrRemoveAnnotation(RelationalAnnotationNames.ComputedColumnIsStored, value, fromDataAnnotation);
property.SetOrRemoveAnnotation(RelationalAnnotationNames.IsStored, value, fromDataAnnotation);

return value;
}
Expand All @@ -771,8 +771,8 @@ public static void SetComputedColumnIsStored([NotNull] this IMutableProperty pro
/// </summary>
/// <param name="property"> The property. </param>
/// <returns> The <see cref="ConfigurationSource" /> for the computed value SQL expression. </returns>
public static ConfigurationSource? GetComputedColumnIsStoredConfigurationSource([NotNull] this IConventionProperty property)
=> property.FindAnnotation(RelationalAnnotationNames.ComputedColumnIsStored)?.GetConfigurationSource();
public static ConfigurationSource? GetIsStoredConfigurationSource([NotNull] this IConventionProperty property)
=> property.FindAnnotation(RelationalAnnotationNames.IsStored)?.GetConfigurationSource();

/// <summary>
/// Returns the object that is used as the default value for the column this property is mapped to.
Expand Down
12 changes: 6 additions & 6 deletions src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,20 +545,20 @@ protected virtual void ValidateCompatible(
currentComputedColumnSql));
}

var currentComputedColumnIsStored = property.GetComputedColumnIsStored(tableName, schema);
var previousComputedColumnIsStored = duplicateProperty.GetComputedColumnIsStored(tableName, schema);
if (currentComputedColumnIsStored != previousComputedColumnIsStored)
var currentStored = property.GetIsStored(tableName, schema);
var previousStored = duplicateProperty.GetIsStored(tableName, schema);
if (currentStored != previousStored)
{
throw new InvalidOperationException(
RelationalStrings.DuplicateColumnNameComputedIsStoredMismatch(
RelationalStrings.DuplicateColumnNameIsStoredMismatch(
duplicateProperty.DeclaringEntityType.DisplayName(),
duplicateProperty.Name,
property.DeclaringEntityType.DisplayName(),
property.Name,
columnName,
Format(tableName, schema),
previousComputedColumnIsStored,
currentComputedColumnIsStored));
previousStored,
currentStored));
}

var currentDefaultValue = property.GetDefaultValue(tableName, schema);
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Relational/Metadata/IColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public virtual object DefaultValue
/// Returns whether the value of the computed column this property is mapped to is stored in the database, or calculated when
/// it is read.
/// </summary>
public virtual bool? ComputedColumnIsStored => PropertyMappings.First().Property.GetComputedColumnIsStored(Table.Name, Table.Schema);
public virtual bool? IsStored => PropertyMappings.First().Property.GetIsStored(Table.Name, Table.Schema);

/// <summary>
/// Comment for this column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static class RelationalAnnotationNames
/// <summary>
/// The name for computed column type annotations.
/// </summary>
public const string ComputedColumnIsStored = Prefix + "ComputedColumnIsStored";
public const string IsStored = Prefix + "IsStored";

/// <summary>
/// The name for default value annotations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ private bool ColumnStructureEquals(IColumn source, IColumn target)
&& source.IsFixedLength == target.IsFixedLength
&& source.Collation == target.Collation
&& source.Comment == target.Comment
&& source.ComputedColumnIsStored == target.ComputedColumnIsStored
&& source.IsStored == target.IsStored
&& source.ComputedColumnSql == target.ComputedColumnSql
&& Equals(source.DefaultValue, target.DefaultValue)
&& source.DefaultValueSql == target.DefaultValueSql;
Expand Down Expand Up @@ -989,7 +989,7 @@ protected virtual IEnumerable<MigrationOperation> Diff(
|| columnTypeChanged
|| source.DefaultValueSql != target.DefaultValueSql
|| source.ComputedColumnSql != target.ComputedColumnSql
|| source.ComputedColumnIsStored != target.ComputedColumnIsStored
|| source.IsStored != target.IsStored
|| !Equals(source.DefaultValue, target.DefaultValue)
|| source.Comment != target.Comment
|| source.Collation != target.Collation
Expand Down Expand Up @@ -1101,7 +1101,7 @@ private void Initialize(

columnOperation.DefaultValueSql = column.DefaultValueSql;
columnOperation.ComputedColumnSql = column.ComputedColumnSql;
columnOperation.ComputedColumnIsStored = column.ComputedColumnIsStored;
columnOperation.IsStored = column.IsStored;
columnOperation.Comment = column.Comment;
columnOperation.Collation = column.Collation;
columnOperation.AddAnnotations(migrationsAnnotations);
Expand Down
Loading