dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.74k stars 3.18k forks source link

Cosmos: review cast/convert handling #34982

Open roji opened 17 hours ago

roji commented 17 hours ago

In general, the logic in CosmosSqlTranslatingEV.VisitUnary for ExpressionType.Convert. See e.g. test Equality_operator_int_to_long.

ChrisJollyAU commented 15 hours ago

@roji Would this be along the lines of a superset of the issue I picked up the other day with the string concatenation (#34963)

Also, I've tried looking but can't find the test you mentioned

roji commented 12 hours ago

Also, I've tried looking but can't find the test you mentioned

Yes, that test is something I'm still working on in a branch. Here it is:

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Equality_operator_int_to_long(bool async)
{
    long arg = 10248;

    return AssertQuery(
        async,
        ss => ss.Set<Order>().Where(o => o.OrderID == arg));
}
roji commented 12 hours ago

Would this be along the lines of a superset of the issue I picked up the other day with the string concatenation

And yeah, it could definitely be related...

ChrisJollyAU commented 11 hours ago

btw, had an idea based on what I have done previously

I can get this sql and it passes

@__arg_0='10248'

SELECT VALUE c
FROM root c
WHERE ((c["$type"] = "Order") AND (c["OrderID"] = @__arg_0))

Am I correct in thinking that Cosmos has some implicit conversions, as I couldn't find much in terms of an explicit cast