Announcement

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

    question about DAtasplitCriteria()

    SmartClient Version: v13.0p_2023-08-29/AllModules Development Only (built 2023-08-29)

    sorry for the mispelled title, should be "questions about DataSource.splitCriteria()"

    Hello, if I define an AdvancedCriteria like this:
    Code:
    var c = {
            _constructor:"AdvancedCriteria",
            operator:"and",
            criteria:[
                {
                    fieldName:"countryName",
                    operator:"iContains",
                    value:"a"
                },
                {
                    fieldName:"population",
                    operator:"lessThan",
                    value:100000
                },
                {
                    fieldName:"independence",
                    operator:"greaterThan",
                    value:"1500-08-02"
                }
            ]
        };
    and than call
    Code:
    worldDS.splitCriteria(c, ["population"]);
    I get this warning:
    Code:
    *11:55:20.994:XRP0:WARN:Log:splitCriteria: advanced criteria second-level operator:and for field:population cannot be converted to simple criteria format
    that "second-level operator:and" part of the message doesn't seem right in this case.

    Second question. If I define another criteria:

    Code:
    var c = {
            _constructor:"AdvancedCriteria",
            operator:"and",
            criteria:[
                {
                    fieldName:"countryCode",
                    operator:"equals",
                    value:"DO"
                },
                {
                    fieldName:"countryName",
                    operator:"iContains",
                    value:"a"
                }
            ]
        };
    and then call
    Code:
    worldDS.splitCriteria(c, ["countryName"]);
    I get no warning, but a simple criteria like this:

    {countryName: 'a'}
    Without a warning...this doesn't seem right. Is it expected?
    Last edited by claudiobosticco; 30 Aug 2023, 04:36. Reason: corrected AdvancedCriteria

    #2
    claudiobosticco you wrote _constructor:"AdavancedCriteria", which has a typo two times.

    Best regards
    Blama

    Comment


      #3
      Hi Blama thanks for the heads up, but the result is the same, I don't think it's a required attribute.

      Comment


        #4
        Is this targeted at our sample worldDS? That date-string isn't valid for a date field.

        Can you show sample code?

        Comment


          #5
          Hello Isomorphic, yes worldDS from the showcase.

          Sorry for the invalid date, but actually the behaviour is the same if you remove that criterion altogether

          Comment


            #6
            Please show your full sample code and we'll take a look - there could be spelling and other mistakes that we can't know about until we see the code.

            Comment


              #7
              SmartClient Version: v13.0p_2023-08-30/AllModules Development Only (built 2023-08-30)

              Chrome on MacOS

              Hello, please try this code in the showcase https://www-demos.smartclient.com/sm...&skin=Twilight

              Code:
              var c = {
                      _constructor:"AdvancedCriteria",
                      operator:"and",
                      criteria:[
                          {
                              fieldName:"countryName",
                              operator:"iContains",
                              value:"a"
                          },
                          {
                              fieldName:"population",
                              operator:"lessThan",
                              value:100000
                          }
                      ]
                  };
              
              isc.logEcho(worldDS.splitCriteria(c, ["population"]))
              I get this WARN:
              Code:
              *17:18:39.020:MUP0:WARN:Log:splitCriteria: advanced criteria second-level operator:and for field:population cannot be converted to simple criteria format
              I get that the population criterion can't be converted to simple criteria, and I must use true as the 3rd argument of splitCriteria, but that "second-level operator:and" part of the message doesn't seem right in this case.

              Then please try this test case:

              Code:
              var c = {
                      _constructor:"AdvancedCriteria",
                      operator:"and",
                      criteria:[
                          {
                              fieldName:"countryCode",
                              operator:"equals",
                              value:"DO"
                          },
                          {
                              fieldName:"countryName",
                              operator:"iContains",
                              value:"a"
                          }
                      ]
                  };
              
              isc.logEcho(worldDS.splitCriteria(c, ["countryName"]));
              this time I get this result:
              Code:
              *17:22:59.037:MUP7:WARN:Log:{countryName: "a"}
              so I get a simple criteria, without a warning, which doesn't seem right, as that criterion isn't really convertible to simple criteria. Is it expected?

              Comment


                #8
                Thanks for the details.

                On the first issue, we've fixed the message that we show at this time, so it includes the right operator (it was including the top-level op rather than the one from the Criterion).

                On the second issue, when converting to simple-criteria, we actually allow a number of operators: equals/iEquals, iContains and startsWith. These essentially map to/imply a textMatchStyle, and iContains is the default for text fields. The logic that does this has been around for quite a while but we're having a discussion about tightening it up/doc-ing it more clearly and we'll update here when we have more information.

                Comment

                Working...
                X