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

Query: Non-tracking query doesn't throw for null keys #26310

Closed
smitpatel opened this issue Oct 11, 2021 · 1 comment · Fixed by #26311
Closed

Query: Non-tracking query doesn't throw for null keys #26310

smitpatel opened this issue Oct 11, 2021 · 1 comment · Fixed by #26311
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Milestone

Comments

@smitpatel
Copy link
Contributor

No description provided.

@roji
Copy link
Member

roji commented Oct 11, 2021

Repro on Cosmos:

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public async Task FromSqlRaw_queryable_simple_with_missing_key_and_non_tracking_throws(bool async)
{
    using var context = CreateContext();
    var query = context.Set<Customer>()
        .FromSqlRaw(@"SELECT * FROM root c WHERE c[""Discriminator""] = ""Category""")
        .AsNoTracking();
    var exception = async
        ? await Assert.ThrowsAsync<InvalidOperationException>(() => query.ToArrayAsync())
        : Assert.Throws<InvalidOperationException>(() => query.ToArray());
    Assert.Equal(CoreStrings.MissingKeyDuringMaterialization(context.Model.FindEntityType(typeof(Customer))!.DisplayName()), exception.Message);
}

@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 11, 2021
@smitpatel smitpatel added this to the 7.0.0 milestone Oct 11, 2021
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-preview1 Feb 14, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-preview1, 7.0.0 Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants