GithubHelp home page GithubHelp logo

Comments (2)

VilleHakli avatar VilleHakli commented on July 27, 2024

We were also hit by this issue when updating from 6.0.0-rc1 to 6.0.0.

The issue might be in IncludePlan<T>.IncludedDocumentStatement in which storage.FilterDocuments is called with null session parameter. This causes the NRE in DocumentStorage<T, TId>.extraFilters.

Here is other failing test which I created before finding this issue:

using System;
using System.Threading.Tasks;

using Bug2583;

using Marten;
using Marten.Testing.Harness;

using Shouldly;

using Weasel.Core;

using Xunit;

namespace DocumentDbTests.Bugs
{
    public class Bug_2583_include_in_query_throw_null_reference_with_multi_tenant_documents: BugIntegrationContext
    {
        [Fact]
        public async Task should_be_able_to_include_multi_tenant_documents()
        {
            using var documentStore = SeparateStore(x =>
            {
                x.AutoCreateSchemaObjects = AutoCreate.All;
                x.Schema.For<TestEntity>().MultiTenanted();
                x.Schema.For<OtherTestEntity>().MultiTenanted();
            });

            await documentStore.Advanced.Clean.DeleteAllDocumentsAsync();

            var testEntityId = Guid.NewGuid();
            var otherTestEntityId = Guid.NewGuid();
            await using (var session = documentStore.LightweightSession("tenant"))
            {
                session.Store(new OtherTestEntity
                {
                    Id = otherTestEntityId,
                    Name = "Other test"
                });

                session.Store(new TestEntity
                {
                    Id = testEntityId,
                    Name = "Test",
                    OtherId = otherTestEntityId
                });

                await session.SaveChangesAsync();
            }

            await using (var session = documentStore.QuerySession("tenant"))
            {
                OtherTestEntity otherTestEntity = null;
                var testEntity = await session.Query<TestEntity>()
                    .Include<OtherTestEntity>(x => x.OtherId, x => otherTestEntity = x)
                    .SingleOrDefaultAsync();

                testEntity.ShouldNotBeNull();
                testEntity.Id.ShouldBe(testEntityId);

                otherTestEntity.ShouldNotBeNull();
                otherTestEntity.Id.ShouldBe(otherTestEntityId);
            }
        }
    }
}

namespace Bug2583
{
    public class TestEntity
    {
        public Guid Id { get; set; }
        public string Name { get; set; }
        public Guid OtherId { get; set; }
    }

    public class OtherTestEntity
    {
        public Guid Id { get; set; }
        public string Name { get; set; }
    }
}

from marten.

oskardudycz avatar oskardudycz commented on July 27, 2024

It seems to me that #2602 should fix it.

from marten.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.