Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Bug with AdvancedCriteria.addCriteria (switching type from OR to AND)

    Hi Isomorphic,

    please see this code excerpt using v10.0p_2015-04-30:

    Code:
    setHilites(new Hilite[] { new Hilite() {
    	{
    		AdvancedCriteria ac = new AdvancedCriteria(OperatorId.OR);
    		ac.addCriteria(new Criterion(currentStatusLGFHidden.getName(), OperatorId.EQUALS, ListGridFieldLeadstatus.DISMISSEDAFTERPICKING));
    		ac.addCriteria(new Criterion(currentStatusLGFHidden.getName(), OperatorId.EQUALS, ListGridFieldLeadstatus.DISMISSEDBEFOREPICKING));
    		setCriteria(ac);
    		setCssText("font-weight:bold; color:#FF0000;");
    	}
    } });
    Following the return of ac.asString() in the debugger:
    After constructor:
    Code:
    {
        "operator":"or", 
        "_constructor":"AdvancedCriteria"
    }
    After 1st addCriteria (bug here):
    Code:
    {
        "operator":"[B]and[/B]", 
        "_constructor":"AdvancedCriteria", 
        "criteria":[
            {
                "fieldName":"STATUS_SHORTNAME", 
                "operator":"equals", 
                "value":"dismissedAfterPicking"
            }
        ]
    }
    After 2nd addCriteria:
    Code:
    {
        "operator":"and", 
        "_constructor":"AdvancedCriteria", 
        "criteria":[
            {
                "fieldName":"STATUS_SHORTNAME", 
                "operator":"equals", 
                "value":"dismissedAfterPicking"
            }, 
            {
                "fieldName":"STATUS_SHORTNAME", 
                "operator":"equals", 
                "value":"dismissedBeforePicking"
            }
        ]
    }
    Best regards
    Blama

    #2
    Hi Isomorphic,

    out of curiosity I tried this, which does not suffer from the bug:
    Code:
    AdvancedCriteria ac = new AdvancedCriteria(OperatorId.OR, new Criterion[] {
    		new Criterion(currentStatusLGFHidden.getName(), OperatorId.EQUALS, ListGridFieldLeadstatus.DISMISSEDAFTERPICKING),
    		new Criterion(currentStatusLGFHidden.getName(), OperatorId.EQUALS, ListGridFieldLeadstatus.DISMISSEDBEFOREPICKING) });
    Best regards
    Blama

    Comment


      #3
      This issue has been solved, and the fix will be available as of 5 May.

      Regards,
      Isomorphic Software

      Comment


        #4
        Hi Isomorphic,

        this is fixed for me using v10.0p_2015-05-19.

        Best regards
        Blama

        Comment


          #5
          Hello Blama, hello Isomorphic,

          as described in the documentation addCriteria have to replace the "or" criteria with a new and criteria:

          Code:
          If the present criteria operation is "and", the new criteria is appended to the criteria list:
          
          Otherwise, the existing criteria is replaced with an "and" criteria, with two sub-criteria: the existing criteria, and the passed criteria.
          
          Note that if the existing criteria was empty (as would happen if new AdvancedCriteria() were called with no arguments), an "and" operator will still be introduced, but the passed criteria will be the only sub-criteria.
          
          To add an additional Criterion when using the "or" operator, use appendToCriterionList(com.smartgwt.client.data.Criterion).
          So, your "fix" from 2015-19-05 crashed this functionality and my application.
          Please revert the changes, so addCriteria works as described.

          This is a urgent request.

          Peter

          Comment


            #6
            The fix here is consistent with the docs. What we changed was just that if you explicitly construct an AdvancedCriteria with "or" as the top-level operator, there is no longer conversion to "and" operator when a sub-criterion is added.

            If you are not explicitly constructing AdvancedCriteria with an "or" operator, this won't effect you. If your code was explicitly specifying an "or" operator but expecting an "and" operator to be the result, you should fix that code.

            If you disagree and you think the fix affected other cases, try putting together a minimal, ready-to-run test case demonstrating an issue.

            Comment


              #7
              Hello,

              here is an example of my code:

              Code:
               
              Criterion criterion1 = new Criterion("startDate", OperatorId.GREATER_OR_EQUAL, startDate);
              Criterion criterion2 = new Criterion("endDate", OperatorId.GREATER_OR_EQUAL, startDate);
              
              AdvancedCriteria exCriteria = new AdvancedCriteria(OperatorId.OR, new Criterion[] { criterion1 , criterion2  });
              
              Criterion criterion3 = new Criterion("type", OperatorId.EQUALS, 1);
              
              exCriteria.addCriteria(criterion3);
              The description say:
              If the present criteria operation is not "and" (here it is "or" and "or" is not equal to "and"), the existing criteria is replaced with an "and" criteria, with two sub-criteria: the existing criteria, and the passed criteria.

              Now the existing criteria is replaced with an "or" criteria, with two sub-criteria: the existing criteria, and the passed criteria.

              That is not the result as you describe in the documentation.

              Peter

              Comment


                #8
                Hello,

                any comment from Isomorphic?

                Peter

                Comment


                  #9
                  Hello,

                  please have look on this thread:
                  http://forums.smartclient.com/showthread.php?t=28401

                  and your answer at 6th Nov 2013, 04:45.

                  Peter

                  Comment


                    #10
                    Oh, that's also my thread...funny.
                    I don't care for the final implementation as I can adjust my code once Isomorphic decides which way it should be.
                    While I think the new/fixed behaviour is more logical and expected by users, I agree with Peter that the new/fixed behaviour is not matching the current docs.

                    Best regards
                    Blama

                    Comment


                      #11
                      The previous fix has been reverted and a new one has been applied so that the final behavior matches with the documentation.
                      The fix will be in nightly builds as of tomorrow, 06/27.

                      Regards,
                      Isomorphic Software

                      Comment

                      Working...
                      X