Skip to content

Commit

Permalink
Update exception messages for optional dependents
Browse files Browse the repository at this point in the history
Address PR feedback
  • Loading branch information
smitpatel committed Apr 6, 2021
1 parent 0a7ad48 commit c7f3b49
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/EFCore.Relational/Properties/RelationalStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@
<comment>Debug RelationalEventId.ConnectionOpening string string</comment>
</data>
<data name="LogOptionalDependentWithoutIdentifyingProperty" xml:space="preserve">
<value>Entity type '{entityType}' is an optional dependent in table sharing without any required non shared property to identify if the entity type exist. If all nullable properties contain null value in database then an object instance won't be materialized in the query.</value>
<comment>Error RelationalEventId.ModelValidationOptionalDependentWithoutIdentifyingPropertyWarning string</comment>
<value>The entity type '{entityType}' is an optional dependent using table sharing without any required non shared property that could be used to identify whether the entity exists. If all nullable properties contain a null value in database then an object instance won't be created in the query. Add a required property to create instances with null values for other properties or mark the incoming navigation as required to always create an instance.</value>
<comment>Warning RelationalEventId.OptionalDependentWithoutIdentifyingPropertyWarning string</comment>
</data>
<data name="LogPossibleUnintendedUseOfEquals" xml:space="preserve">
<value>Possible unintended use of method 'Equals' for arguments '{left}' and '{right}' of different types in a query. This comparison will always return false.</value>
Expand Down Expand Up @@ -680,7 +680,7 @@
<value>Expression '{sqlExpression}' in the SQL tree does not have a type mapping assigned.</value>
</data>
<data name="OptionalDependentWithDependentWithoutIdentifyingProperty" xml:space="preserve">
<value>Entity type '{entityType}' is an optional dependent containing other dependents in table sharing without any required non shared property to identify if the entity type exist. If all nullable properties contain null value in database then an object instance won't be materialized in the query causing nested dependent's values to be lost.</value>
<value>Entity type '{entityType}' is an optional dependent using table sharing and containing other dependents without any required non shared property to identify whether the entity exists. If all nullable properties contain a null value in database then an object instance won't be created in the query causing nested dependent's values to be lost. Add a required property to create instances with null values for other properties or mark the incoming navigation as required to always create an instance.</value>
</data>
<data name="ParameterNotObjectArray" xml:space="preserve">
<value>Cannot use the value provided for parameter '{parameter}' because it isn't assignable to type object[].</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public virtual void Passes_on_not_configured_shared_columns_with_shared_table()
}

[ConditionalFact]
public virtual void Throws_on_not_configured_shared_columns_with_shared_table()
public virtual void Throws_on_not_configured_shared_columns_with_shared_table_with_dependents()
{
var modelBuilder = CreateConventionalModelBuilder();

Expand All @@ -348,6 +348,17 @@ public virtual void Throws_on_not_configured_shared_columns_with_shared_table()
VerifyError(RelationalStrings.OptionalDependentWithDependentWithoutIdentifyingProperty(nameof(A)), modelBuilder.Model);
}

[ConditionalFact]
public virtual void Warns_on_not_configured_shared_columns_with_shared_table()
{
var modelBuilder = CreateConventionalModelBuilder();

modelBuilder.Entity<Owner>().OwnsOne(e => e.Owned);

var definition = RelationalResources.LogOptionalDependentWithoutIdentifyingProperty(new TestLogger<TestRelationalLoggingDefinitions>());
VerifyWarning(definition.GenerateMessage(nameof(OwnedEntity)), modelBuilder.Model);
}

[ConditionalFact]
public virtual void Detects_incompatible_shared_columns_with_shared_table()
{
Expand Down Expand Up @@ -2000,6 +2011,17 @@ protected class Employee : Person
{
}

protected class Owner
{
public int Id { get; set; }
public OwnedEntity Owned { get; set; }
}

protected class OwnedEntity
{
public string Value { get; set; }
}

public class TestDecimalToLongConverter : ValueConverter<decimal, long>
{
private static readonly Expression<Func<decimal, long>> convertToProviderExpression = d => (long)(d * 100);
Expand Down

0 comments on commit c7f3b49

Please sign in to comment.