Announcement

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

    12.0p Hard to debug issue with ListGrid implicitCriteria becoming broken after fetch

    Hi Isomorphic,

    please see this 12.0p based testcase (v12.0p_2018-12-14).
    Preface: I'm not 100% sure the SmartClient line
    Code:
    implicitCriteria: { _constructor:"AdvancedCriteria", fieldName: "units", operator: "isNull" },
    is correct, but it happens the same in my SmartGWT application using
    Code:
    setImplicitCriteria(new AdvancedCriteria("STATUS_WONLOST_ID", OperatorId.IS_NULL));
    Testcase:
    Code:
    isc.ListGrid.create({
        ID:"dsListGrid", 
        width: "100%",
        height: "100%",
        autoFetchData: false,
        canEdit: true,
        initialSort: [
            {property: "category", direction: "ascending"},
            {property: "units", direction: "ascending"}
        ],
        dataSource: "supplyItem",
        showFilterEditor: true,
        implicitCriteria: { _constructor:"AdvancedCriteria", fieldName: "units", operator: "isNull" },
    });
    
    isc.IButton.create({
        ID:"fetchButton", width: 200,
        title:"Fetch no criteria",
        click : function () {
            dsListGrid.fetchData();
        }
    });
    
    isc.IButton.create({
        ID:"fetchFilteredButton", width: 200,
        title:"units criteria fetchData()",
        click : function () {
            dsListGrid.fetchData({ _constructor: "AdvancedCriteria", fieldName: "units", operator: "equals", value: "Ea"});
        }
    });
    
    isc.IButton.create({
        ID:"showImplicitCriteria", width: 200,
        title:"Show ImplicitCriteria",
        click : function () {
            isc.say(dsListGrid.getImplicitCriteria())
        }
    });
    
    isc.HStack.create({
        ID:"hStack",
        membersMargin:10,
        members:[ fetchButton, fetchFilteredButton, showImplicitCriteria]
    });
    
    isc.VLayout.create({
        membersMargin:10,
        width: "100%",
        height: "100%",
        members:[ dsListGrid, hStack]
    });
    Now, do these steps:
    1. Developer Console, Results, Evaluate JS Expression: "dsListGrid.getImplicitCriteria()"
      Evaluator: result of 'dsListGrid.getImplicitCriteria()' (0ms):
      {_constructor: "AdvancedCriteria",
      fieldName: "units",
      operator: "isNull"}
    2. Click "Fetch no criteria", data fetched as expected, in DSRequest this is to see, as expected:
      data:{
      fieldName:"units",
      operator:"isNull"
      },
    3. Repeat step 1, same result (as expected)
    4. Click "units criteria fetchData()", data fetched as expected, in DSRequest this is to see, not expected:
      data:{
      operator:"and",
      criteria:[
      {
      operator:"and",
      criteria:[
      {
      fieldName:"fieldName",
      operator:"iContains",
      value:"units"
      },
      {
      fieldName:"operator",
      operator:"iContains",
      value:"equals"
      },
      {
      fieldName:"value",
      operator:"iContains",
      value:"Ea"
      }
      ]
      },
      {
      fieldName:"units",
      operator:"isNull"
      }
      ]
      },
    5. Repeat step 1, different result (not expected)
      Evaluator: result of 'dsListGrid.getImplicitCriteria()' (0ms):
      {fieldName: "units",
      operator: "isNull"}


    I also did the same in my application (see the setImplicitCriteria() call above) and compared good and bad requests.
    Here there is one detail, which makes it VERY hard to analyse it serverside where one request hard the expected WHERE clause and the the other just WHERE '1' = '1'.
    (This does not happen 1:1 the same in the testcase)

    "DSRequest"-Tab compared (good left, bad right; important parts the same):
    Click image for larger version

Name:	DSRequest.png
Views:	100
Size:	183.7 KB
ID:	256166

    "RPCRequest"-Tab of the same requests compared (good left, bad right; see the missing "_constructor"-line):
    Click image for larger version

Name:	RPCRequest.png
Views:	65
Size:	216.0 KB
ID:	256167

    I'm not sure whether the error in the Developer Console in the DSRequest-Tab or RPCRequest-Tab, but I assume the former.

    The main issue is the modification of the implicitCriteria by just a fetch.

    This is an important one for me.

    Best regards
    Blama

    #2
    If you just get rid of the _constructor declarations in both sets of criteria, you should see better behavior - if you then look at the request you'll see a properly formatted advancedCriteria.

    However - you will also see that the criteria passed in the call to fetchData() from the middle button essentially clobbers the implicitCriteria - we're taking a look into that

    Comment


      #3
      In fact, you can have this work as expected by just providing a fully declared AdvancedCriteria:

      Code:
          implicitCriteria: { _constructor: "AdvancedCriteria", operator: "and",
              criteria: [ { fieldName: "units", operator: "isNull" } ]
          }
      With this criteria format, the implicitCriteria is correctly combined at runtime and, in your sample above, clicking the middle button returns no rows (because "units" values can't be both null and Ea).
      Last edited by Isomorphic; 14 Dec 2018, 05:55.

      Comment


        #4
        Hi Isomorphic,

        the clobbering that happens is essentially the main issue, yes.

        I did start without the "_constructor: "AdvancedCriteria" (which has the same problem) but were not sure it is correct if I want to use operators, so I changed it.
        I assumed so, as the when the clobbering happens, you can see a difference in "Eval JS": dsListGrid.getImplicitCriteria() only if you do use the "_constructor: "AdvancedCriteria".

        Also, the issue with the different output in DSRequest and RPCRequest seems pretty strange and important to me, because it might lead to big confusion, as it did for me now.

        Best regards
        Blama

        Comment


          #5
          Hi Isomorphic,

          my #4 was without seeing #3.

          As I said, I'm using this in SmartGWT:
          Code:
          setImplicitCriteria(new AdvancedCriteria("STATUS_WONLOST_ID", OperatorId.IS_NULL));
          IMHO This is a valid constructor for AdvancedCriteria and results in the same issue. I'm not sure where the problem here is.

          Best regards
          Blama

          Comment


            #6
            Hi Isomorphic,

            short update. Using this line which matches your code in #3 fixes the issue in my SmartGWT application for me:
            Code:
            setImplicitCriteria(new AdvancedCriteria(OperatorId.AND,
               new Criterion[] {
                    new Criterion("STATUS_WONLOST_ID", OperatorId.IS_NULL)
               }
            ));
            But I do think there is either some clobbering issue anyway or some general AdvancedCriteria/Criteria issue.

            Thank you & Best regards
            Blama

            Comment


              #7
              Yes, we agree - we'll look into why criteria-combination isn't working fully with implicitCriteria in the format you tried to use.

              Comment


                #8
                Hi Isomorphic,

                any update on this one? It's working for me with the workaround, but should be fixed for all use cases.

                Best regards
                Blama

                Comment


                  #9
                  We've just fixed it - you can retest with tomorrow's builds.

                  Comment


                    #10
                    Hi Isomorphic

                    I just retested with v12.0p_2019-01-24 and the sample from #1. The issue is still open IMHO:

                    The implicitCriteria: { _constructor:"AdvancedCriteria" is not there anymore after the fetch.

                    Also (new issue) the "Show ImplicitCriteria" button does return this error:
                    Code:
                    09:33:32.988:MUP0:WARN:Log:TypeError: this.message.evalDynamicString is not a function
                    Stack from error.stack:
                        Dialog.createChildren(<no args: exited>) on [Dialog ID:isc_globalWarn] @ ISC_Containers.js:236:21
                        _3.showMessage(<no args: exited>) on [Dialog ID:isc_globalWarn] @ ISC_Containers.js:249:84
                        <anonymous>(<no args: exited>) @ ISC_Containers.js:261:112
                        <anonymous>(<no args: exited>) @ ISC_Containers.js:262:119
                        _3.click(<no args: exited>) on [IButton ID:showImplicitCriteria] @ [no file]:154:13
                        StatefulCanvas.handleActivate(<no args: exited>) on [IButton ID:showImplicitCriteria] @ ISC_Foundation.js:236:108
                        StatefulCanvas.handleClick(<no args: exited>) on [IButton ID:showImplicitCriteria] @ ISC_Foundation.js:237:13
                        [c]EventHandler.bubbleEvent(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:2147:89
                        [c]EventHandler.handleClick(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1981:50
                        EventHandler._handleMouseUp(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1965:11
                        [c]EventHandler.handleMouseUp(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1956:57
                        [c]EventHandler.dispatch(_1=>[c]EventHandler.handleMouseUp(), _2=>[object MouseEvent]) on [Class EventHandler] @ ISC_Core.js:2234:108
                        HTMLDocument.eval(event=>[object MouseEvent]) @ [no file]:3:123
                    subsequent clicks of the button show this:
                    Code:
                    09:36:25.048:MUP5:WARN:Log:TypeError: Cannot read property 'setContents' of undefined
                    Stack from error.stack:
                        _3.showMessage(<no args: exited>) on [Dialog ID:isc_globalWarn] @ ISC_Containers.js:249:119
                        <anonymous>(<no args: exited>) @ ISC_Containers.js:261:112
                        <anonymous>(<no args: exited>) @ ISC_Containers.js:262:119
                        _3.click(<no args: exited>) on [IButton ID:showImplicitCriteria] @ [no file]:154:13
                        StatefulCanvas.handleActivate(<no args: exited>) on [IButton ID:showImplicitCriteria] @ ISC_Foundation.js:236:108
                        StatefulCanvas.handleClick(<no args: exited>) on [IButton ID:showImplicitCriteria] @ ISC_Foundation.js:237:13
                        [c]EventHandler.bubbleEvent(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:2147:89
                        [c]EventHandler.handleClick(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1981:50
                        EventHandler._handleMouseUp(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1965:11
                        [c]EventHandler.handleMouseUp(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1956:57
                        [c]EventHandler.dispatch(_1=>[c]EventHandler.handleMouseUp(), _2=>[object MouseEvent]) on [Class EventHandler] @ ISC_Core.js:2234:108
                        HTMLDocument.eval(event=>[object MouseEvent]) @ [no file]:3:123
                    Best regards
                    Blama

                    Comment


                      #11
                      The runtime errors you reported at the end are a result of you passing an object to isc.say(), which is doc'd as expecting a string - we've tweaked the framework to stringify such parameters as a fallback, but you should pass a string - you can just wrap the object with isc.echo(...) in the meantime.

                      The problem with the _constructor being removed from the implicitCriteria was a case where internal framework code was passing the grid's implicitCriteria around by reference, which allowed it to be affected by internal operations such as criteria combination and flattening/simplification. The criteria was still considered advanced, on account of having a fieldName and an operator and (in the case of this particular operator) no value - so should still be functional.

                      We've fixed the problem anyway,. for builds dated January 27 and later.

                      Comment

                      Working...
                      X