-
-
Notifications
You must be signed in to change notification settings - Fork 453
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
Include does not work after migrating to v7.26.1 from v6 #3351
Comments
It's very likely that the problem -- and it may well be a Marten issue -- is in whatever Select() transform you're doing inside of your code here: .ForAllTokens()
.ForSomeTokens() We've had some issues in the past with the combo of Include() + Select(). Also make sure you're on the very latest version of Marten because there was a fix for Include() + Select() + ToPagedListAsync() in the very last release. |
Using the latest version of Marten v7.26.1. |
It throws same error without any where conditions // no where, no select, no token // throws error // but this works |
@bhosale-ajay Let me try again, I need more detailed information from you about the types you're using, the exact where clause, everything. We have existing tests that cover the combination of things you're trying to do, so it's not a generalized "it doesn't work". There's something about the exact permutation of what you're doing that is failing. I need to know that to have any chance at helping you here. |
I will share a repo with combinations to reproduce the error. Thanks for the quick response. |
Here is complete code. // Program.cs using Marten;
using Marten.Pagination;
using Weasel.Core;
const string connectionString = "host=localhost;database=demo_db;";
var store = DocumentStore.For(
options =>
{
options.Connection(connectionString);
options.AutoCreateSchemaObjects = AutoCreate.All;
options.Schema.For<User>();
options.Schema.For<UserInformation>();
}
);
await using var session = store.QuerySession();
var userInfo = new Dictionary<string, UserInformation>();
var users = await session
.Query<User>()
.Include(userInfo).On(x => x.Id!)
// .ToListAsync(); // This works
.ToPagedListAsync(1, 1); // This does not
Console.WriteLine(users.Count);
public class User
{
public string? Id { get; set; }
public string? FirstName { get; set; }
}
public class UserInformation
{
public string? Id { get; set; }
public string? Company { get; set; }
} // The project references <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Marten" Version="7.26.1" />
</ItemGroup>
</Project> |
Stack Trace
|
After further testing I found that this works only with v6.4.1 (with change in Include syntax - which is no longer supported after v7.10.x). Even v7.0.0 does not work. Code which works for v6.4.1 but not for v7.0.0
With all other code same as posted above. |
@bhosale-ajay So first off, thank you for the bug reproduction because that's hugely helpful. But, "works on my box". Do you maybe have some stale, pre-generated code leftover from the V6 version of your system? This worked out of the box on master -- and better, because there are a lot of people using this and there's a lot of existing test coverage that all passes as well. I'm closing this with another test you'll see linked to from the commit w/ your repro steps. |
After cloning the Marten repository and running my test code by adding a new project to the solution found following difference after debugging. SQL statements generated when running tests drop table if exists mt_temp_id_list1;
create temp table mt_temp_id_list1 as (select d.id, d.data, count(*) OVER() as total_rows from bugs.mt_doc_user3351 as d LIMIT $1);
select d.id, d.data from bugs.mt_doc_userinformation3351 as d where d.id in (select d.id from mt_temp_id_list1 as d);
select * from mt_temp_id_list1 as d; SQL statements generated when running project drop table if exists mt_temp_id_list1;
create temp table mt_temp_id_list1 as (select d.data, count(*) OVER() as total_rows from public.mt_doc_user3351 as d LIMIT $1);
select d.data from public.mt_doc_userinformation3351 as d where d.id in (select d.id from mt_temp_id_list1 as d);
select * from mt_temp_id_list1 as d; Notice the temp table |
Created pull request #3356, Please check this branch. Steps
Please let me know if you can see zero or an error. |
@bhosale-ajay See my comments. I don't see any point in this. The test already passed. Did you ever check for stale pre-generated code? |
There is no pre-generated code. As I can see there is clear difference between SQL batch statements that's get generated when running tests and when running outside tests. Can you please run console app on the PR branch I created and see if you can run it? |
@jeremydmiller - There is a the difference in "SelectFields" when running tests and when running that console program (no pregenerated code). Any idea? |
If drop table if exists mt_temp_id_list1;
create temp table mt_temp_id_list1 as (select d.data, d.id from public.mt_doc_user3351 as d);
select d.data from public.mt_doc_userinformation3351 as d where d.id in (select d.id from mt_temp_id_list1 as d);
select d.data, d.id from mt_temp_id_list1 as d For |
For future reference, solution is to use |
Two entities
Both are built out of projections
The last line throws below error.
Actual Command
Is this a known issue, or misconfiguration with
Include
? The query works well after removing the include.The text was updated successfully, but these errors were encountered: