Skip to content
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

ArgumentNullException on update #4

Open
kassiokiarelly opened this issue Dec 22, 2015 · 5 comments
Open

ArgumentNullException on update #4

kassiokiarelly opened this issue Dec 22, 2015 · 5 comments
Labels

Comments

@kassiokiarelly
Copy link

Method: public static ModificationResult Update(this Session session, Expression<Func> evaluator, CriteriaOperator criteria) where T : IXPObject

Line: List collection = UpdateQueryGenerator.GenerateUpdate(classInfo, properties, ObjectGeneratorCriteriaSet.GetCommonCriteriaSet(criteria), batchWideData);

Version: 15.2.4

@shamp00
Copy link
Member

shamp00 commented Dec 23, 2015

I do not get any error with 15.2.4. I have updated the source code to the DevExpress 15.2.4 and all tests are passing.

@shamp00 shamp00 closed this as completed Dec 23, 2015
@kassiokiarelly
Copy link
Author

The error occurs when i use a criteria (BinaryOperador) that causes a join.

@shamp00
Copy link
Member

shamp00 commented Dec 23, 2015

Ok I can replicate the problem now. Did this work in 15.2.3?

@shamp00 shamp00 reopened this Dec 23, 2015
@kassiokiarelly
Copy link
Author

I did not test in 15.2.3.

@shamp00 shamp00 added the bug label Dec 24, 2015
@shamp00
Copy link
Member

shamp00 commented Dec 24, 2015

Thanks for reporting this issue. I've looked around and it looks like it's not new. I guess criteria with joins have not been supported by XpoBatch for a long time, if ever. For instance, this issue T131050 in the DevExpress support center is the same issue and is two years old.

For now I'm adding a test which demonstrates the issue, and I'll update this issue again in the new year when I've had time to investigate further.

[Test]
/// This test fails because it requires a join in the criteria. 
/// BaseQueryGenerator.AppendJoinNode get called with the Alias property of the
/// prevNode parameter set to null.
public void Test_ModifySome_String_WithReferenceCriteria()
{
    CriteriaOperator criteria = MySimpleObject.Fields.ReferenceProperty.StringProperty == "B%";
    using (UnitOfWork uow = new UnitOfWork(DefaultDataLayer))
    {
        int affectedRecords = uow.GetObjectCount<MySimpleObject>(MySimpleObject.Fields.StringProperty == "abcdefghjiklmnopqrstuvwxyz" & !criteria)
                            + uow.GetObjectCount<MySimpleObject>(criteria);
        uow.Update<MySimpleObject>(() => new MySimpleObject(uow) { StringProperty = "abcdefghjiklmnopqrstuvwxyz" }, criteria);
        Assert.AreEqual(affectedRecords, uow.GetObjectCount<MySimpleObject>(MySimpleObject.Fields.StringProperty == "abcdefghjiklmnopqrstuvwxyz"));
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants