Re: [RavenDB] Unable to load multiple documents at once.

44 views
Skip to first unread message

Kijana Woodard

unread,
May 25, 2013, 10:00:35 PM5/25/13
to rav...@googlegroups.com

This should work. Can you post a full failing test so we can see how you are storing the documents?

On May 25, 2013 5:35 PM, "esskar ." <ess...@gmail.com> wrote:
Hello,

i am trying to load multiple documents by id at once.

        var attributeId1 = "this id exists.";
    var attributeId2 = "this id does not exist.";

    var userAttributes = session
        .Load<UserAttribute>(attributeId1, attributeId2);

This returns an array of 2 elemnts. Both values in the array are null.

Then i tried the following

    var test = session
        .Load<UserAttribute>(attributeId1);

test points now to the document.

When i return the loading after the test load,

    var userAttributes = session
        .Load<UserAttribute>(attributeId1, attributeId2);

It returns an array of 2 elements, but this time userAttributes[0] points to the document.

Any clues?

Raven is ready to process requests. Build 2360, Version 2.0.3 / 4ab4776

Regards,
--esskar

--
You received this message because you are subscribed to the Google Groups "ravendb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

esskar .

unread,
May 26, 2013, 4:08:54 PM5/26/13
to rav...@googlegroups.com
Well, here is a complete test.

    [TestClass]
    public class RavenTests
    {
        private DocumentStore _documentStore;

        [TestInitialize]
        public void Initialize()
        {
            _documentStore = new DocumentStore { ConnectionStringName = "raven_" + Environment.MachineName };
            _documentStore.Initialize();
        }

        [TestMethod]
        public void InsertAndSingleSelect()
        {
            var expected = new Bar {Id = "test/bar/1", Foo = "Some value"};
            using (new TransactionScope())
            {
                using (var session = _documentStore.OpenSession())
                {
                    session.Store(expected);
                    session.SaveChanges();
                }
                using (var session = _documentStore.OpenSession())
                {
                    var actual = session.Load<Bar>(expected.Id);
                    Assert.AreEqual(expected.Id, actual.Id, "Id mismatch.");
                    Assert.AreEqual(expected.Foo, actual.Foo, "Foo mismatch");
                }
            }
        }

        [TestMethod]
        public void InsertAndMultiSelect()
        {
            var expected = new Bar { Id = "test/bar/1", Foo = "Some value" };
            using (new TransactionScope())
            {
                using (var session = _documentStore.OpenSession())
                {
                    session.Store(expected);
                    session.SaveChanges();
                }
                using (var session = _documentStore.OpenSession())
                {
                    var actualList = session.Load<Bar>(expected.Id, "i do not exist");
                    Assert.AreEqual(2, actualList.Length, "Count mismatch.");
                    Assert.IsNotNull(actualList[0], "First element should not be null.");
                    Assert.IsNull(actualList[1], "Second element should be null.");
                    Assert.AreEqual(expected.Id, actualList[0].Id);
                    Assert.AreEqual(expected.Foo, actualList[0].Foo);
                }
            }
        }

        public class Bar
        {
            public string Id { get; set; }

            public string Foo { get; set; }
        }
    }


The InsertAndSingleSelect is successful, but InsertAndMultiSelect fails with

Assert.IsNotNull failed. First element should not be null.

The TransactionScope is just for the purpose of keeping the DB clean. It also fails without it.

Kijana Woodard

unread,
May 26, 2013, 10:20:46 PM5/26/13
to rav...@googlegroups.com
Interestingly, this passes: https://gist.github.com/kijanawoodard/5654842

I'm using Embedded for the tests so I don't need TransactionScope to clean up.
I also changed to use nunit. Not sure if there is a difference in the way the test runner behaves.

Then I changed initialize to:
_documentStore = new DocumentStore() { DefaultDatabase = "test-load-multiple", Url = "http://localhost:8080" };

That was against a 2581 server. Passed.

Then I turned on a 2330 server. Passed. 
I even made sure to run just the failing test so the first test wouldn't alter the result.
I didn't even create the database, I let the test create the database for me so I was sure there was no existing data.

The differences I can see are
TransactionScope - which you ruled out
Testing Framework
Connection String - what does yours look like?

Oren Eini (Ayende Rahien)

unread,
May 27, 2013, 7:11:27 AM5/27/13
to ravendb
Reproduced and found the problem.
Will be fixed in the next build.

Kijana Woodard

unread,
May 27, 2013, 8:35:46 AM5/27/13
to rav...@googlegroups.com
Interesting. What's the repro?

Oren Eini (Ayende Rahien)

unread,
May 27, 2013, 9:34:25 AM5/27/13
to ravendb
Basically, we didn't send the tx info for multi load

Kijana Woodard

unread,
May 27, 2013, 9:42:33 AM5/27/13
to rav...@googlegroups.com
Hmmm. So it was related to TransactionScope?

Oren Eini (Ayende Rahien)

unread,
May 27, 2013, 9:43:09 AM5/27/13
to ravendb
Yes

Sascha Kiefer

unread,
May 27, 2013, 9:48:04 AM5/27/13
to rav...@googlegroups.com, ravendb
strange. the original code did not use a transaction, i believe. but i will recheck. but thanks for fixing.

Sent from my iPhone
You received this message because you are subscribed to a topic in the Google Groups "ravendb" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/9MxVQZyNMSA/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to ravendb+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages