You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Repro:
CoreTests.ShouldQueryInnerSelect currently have this assert: Assert.Equal(1, await session.Query<Person, PersonByAge>().Where(x => x.Name.IsIn<PersonByName>(y => y.Name, y => y.Name.StartsWith("B") || y.Name.StartsWith("C"))).CountAsync());
Which generates this query:
SELECT FROM "tpDocument"
INNER JOIN "tpPersonByAge"
ON "tpPersonByAge"."DocumentId" = "tpDocument"."Id"
WHERE "tpPersonByAge"."Name"
IN (SELECT **"tpPersonByName"."Name"**
FROM "tpPersonByName"
WHERE (("tpPersonByName"."Name" like @p0) or ("tpPersonByName"."Name" like @p1)))
GROUP BY HAVING ORDER BY
Modify the select expression to return Id instead of Name: Assert.Equal(1, await session.Query<Person, PersonByAge>().Where(x => x.Name.IsIn<PersonByName>(y => y.Id, y => y.Id==0)).CountAsync());
And it will generate this query:
SELECT FROM "tpDocument"
INNER JOIN "tpPersonByAge"
ON "tpPersonByAge"."DocumentId" = "tpDocument"."Id"
WHERE "tpPersonByAge"."Name"
IN (SELECT **"tpPersonByName"."Name"**
FROM "tpPersonByName"
WHERE ("tpPersonByName"."Id" = @p0))
GROUP BY HAVING ORDER BY
I think in the inner select it should be "tpPersonByName"."Id" but it generates "tpPersonByName"."Name".
The issue comes from DefaultQuery MethodMappings[typeof(DefaultQueryExtensionsIndex).GetMethod("IsIn")] where the select fragment is generated:
And here in the ConvertFragment the expression's 1. argument should be used intead of the 0. I checked what will happen if I use the 1. argument but the ConvertFragment method is too complex for me but I think you'll know what to do. query.ConvertFragment(_builder, expression.Arguments[0]);
Repro:
CoreTests.ShouldQueryInnerSelect currently have this assert:
Assert.Equal(1, await session.Query<Person, PersonByAge>().Where(x => x.Name.IsIn<PersonByName>(y => y.Name, y => y.Name.StartsWith("B") || y.Name.StartsWith("C"))).CountAsync());
Which generates this query:
Modify the select expression to return Id instead of Name:
Assert.Equal(1, await session.Query<Person, PersonByAge>().Where(x => x.Name.IsIn<PersonByName>(y => y.Id, y => y.Id==0)).CountAsync());
And it will generate this query:
I think in the inner select it should be "tpPersonByName"."Id" but it generates "tpPersonByName"."Name".
The issue comes from DefaultQuery MethodMappings[typeof(DefaultQueryExtensionsIndex).GetMethod("IsIn")] where the select fragment is generated:
And here in the ConvertFragment the expression's 1. argument should be used intead of the 0. I checked what will happen if I use the 1. argument but the ConvertFragment method is too complex for me but I think you'll know what to do.
query.ConvertFragment(_builder, expression.Arguments[0]);
Related to OrchardCMS/OrchardCore#1568
The text was updated successfully, but these errors were encountered: