Skip to content

Fix TargetInvocationException with non nullable value types with HasConversion - #3920

Open
henriquewr wants to merge 1 commit into
npgsql:mainfrom
henriquewr:targetInvocationNonNullable
Open

henriquewr wants to merge 1 commit into
npgsql:mainfrom
henriquewr:targetInvocationNonNullable

Conversation

@henriquewr

Copy link
Copy Markdown
Contributor

fixes #3919

I'm almost 100% certain that this also fixes #3716
seems to be the same stack trace


SELECT p."Id", p."Bool", p."Bools", p."DateTime", p."DateTimes", p."Enum", p."Enums", p."Int", p."Ints", p."NullableInt", p."NullableInts", p."NullableString", p."NullableStrings", p."NullableWrappedId", p."NullableWrappedIdWithNullableComparer", p."String", p."Strings", p."WrappedId"
FROM "PrimitiveCollectionsEntity" AS p
WHERE NOT (p."NullableWrappedId" = ANY (@values) AND p."NullableWrappedId" = ANY (@values) IS NOT NULL) AND (p."NullableWrappedId" IS NOT NULL OR array_position(@values, NULL) IS NULL)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be NullableWrappedIdWithNullableComparer in the WHERE clause?

base test:

[Fact] // Issue #35117
public virtual async Task Parameter_collection_of_structs_Contains_nullable_struct_with_nullable_comparer()
{
    var values = new List<WrappedId> { new(22), new(33) };

    await AssertQuery(
        ss => ss.Set<PrimitiveCollectionsEntity>().Where(c => values.Contains(c.NullableWrappedIdWithNullableComparer!.Value)),
        ss => ss.Set<PrimitiveCollectionsEntity>().Where(c
            => c.NullableWrappedIdWithNullableComparer != null && values.Contains(c.NullableWrappedIdWithNullableComparer.Value)));

    values = [new(11), new(44)];

    await AssertQuery(
        ss => ss.Set<PrimitiveCollectionsEntity>().Where(c => !values.Contains(/*Here*/c.NullableWrappedId!.Value)),
        ss => ss.Set<PrimitiveCollectionsEntity>().Where(c
            => c.NullableWrappedIdWithNullableComparer == null || !values.Contains(c.NullableWrappedIdWithNullableComparer!.Value)));
}

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant