From 8a2d301a11482c5b2f65e2ceae808c82ddd3ef85 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Thu, 31 Oct 2024 02:32:22 -0700 Subject: [PATCH] `UnusedLetImpactsQueryTest` test to reproduce `let impacts query` bug --- Orm/Xtensive.Orm.Tests/Linq/InTest.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Orm/Xtensive.Orm.Tests/Linq/InTest.cs b/Orm/Xtensive.Orm.Tests/Linq/InTest.cs index 05a57056c1..ff8ebad931 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/InTest.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/InTest.cs @@ -583,6 +583,23 @@ public void CompiledInTest() Assert.AreEqual("Leonie", result2[0]); } + [Test] + public void UnusedLetImpactsQueryTest() + { + var allIds = Session.Query.All().Select(o => o.InvoiceId).ToArray(); + var existingIds = allIds.Take(2).ToArray(); + var nonExistingIds = new[] { allIds.Max() + 1 }; + var count1 = (from invoice in Session.Query.All() + where invoice.InvoiceId.In(existingIds) + select invoice).Count(); + var count2 = (from invoice in Session.Query.All() + let foo = invoice.InvoiceId.In(nonExistingIds) + where invoice.InvoiceId.In(existingIds) + select invoice).Count(); + Assert.Greater(count1, 0); + Assert.Greater(count2, 0); + } + private IEnumerable GetCustomers(params string[] customerNames) { return Session.Query.Execute(qe => qe.All().Where(customer => customer.FirstName.In(customerNames)));