Announcement

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

    ListGrid.autoSaveEdits and null values in criteria

    Hello, quoting from
    https://forums.smartclient.com/forum...esyncoperation

    Originally posted by Isomorphic View Post
    Have you tried submitting ID_APP as an explicit null? We wouldn't want to assume absence of a value is equivalent to null; that seems like a gotcha for typical cases of unique checks.
    Originally posted by claudiobosticco View Post
    Thanks for the hint, setting a default of null (using startEditingNew) works.
    Now, I've found a strange behaviour, I don't know if it's by design or if could be a bug

    I've got a grid where I do:
    Code:
    grid.startEditingNew({foo:null, bar:null});
    to have the nulls submitted and used as criteriaFields of a isUnique validator.

    The problem is that if I have autoSaveEdits: false for the grid, the nulls aren't submitted. Is it expected?

    #2
    ListGrid.autoSaveEdits should not cause these explicit nulls to be dropped when the values are saved to the server, and in our testing we're not seeing this behavior.

    If you can put together a simple, runnable test case that demonstrates this we'll be happy to have a look.

    Regards
    Isomorphic Software

    Comment


      #3
      SmartClient Version: SNAPSHOT_v12.1d_2019-09-27/Enterprise Development Only (built 2019-09-27)

      Chrome on OSX

      Hello, I've modified the DBuniqueCheckValidation sample.
      Js code:
      Code:
      isc.ListGrid.create({
          ID:"fooGrid",
          width:500,
          height:200,
          canEdit:true,
          autoFetchData:true,
          autoSaveEdits:false,
          dataSource:"queuing_userHB",
          gridComponents: [isc.ToolStrip.create({
              width: "100%",
              height: 32,
              padding: 0,
              members: [
                  isc.LayoutSpacer.create({width: "*"}),
                  isc.IButton.create({
                      title: "Add new row",
                      click: function () {
                          fooGrid.startEditingNew({firstName:null});
                      }
                  })
              ]
          }), "filterEditor", "header", "body"],
          canRemoveRecords:true,
          fields:[
              {name:"email"},
              {name:"firstName"}
          ]
      });
      queuing_userHB.ds.xml:
      Code:
      <DataSource
          ID="queuing_userHB"
          serverType="hibernate"
          beanClassName="com.isomorphic.examples.server.queuing.User"
          testFileName="/examples/shared/ds/serverExamples/test_data/queuing_user.data.xml"
      >
          <fields>
              <field name="userID" type="sequence" primaryKey="true" canEdit="false" />
              <field name="firstName" type="text" />
              <field name="surname" type="text" />
              <field name="department" type="text" />
              <field name="email" type="text" required="true">
                <validators>
                  <validator type="isUnique" criteriaFields="firstName"/>
                </validators>
              </field>
          </fields>
      
      </DataSource>
      1. press 'add new row' and type kamirov@server.com
      2. press enter

      due to autoSaveEdits:false, it will raise a validation request, which doesn't contain the 'firstName:null' :

      Code:
      === 2019-09-27 13:50:59,893 [ec-3] INFO  RequestContext - URL: '/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36': Safari with Accept-Encoding header
      === 2019-09-27 13:50:59,900 [ec-8] INFO  RequestContext - URL: '/isomorphic/skins/Tahoe/images/actions/remove.png', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36': Safari with Accept-Encoding header
      === 2019-09-27 13:50:59,908 [ec-3] DEBUG XML - Parsed XML from (in memory stream): 14ms
      === 2019-09-27 13:50:59,909 [ec-3] DEBUG RPCManager - Processing 1 requests.
      === 2019-09-27 13:50:59,910 [ec-3] INFO  HB4Provider - Getting mapping: com.isomorphic.examples.server.queuing.User
      === 2019-09-27 13:50:59,910 [ec-3] INFO  HB4Provider - Getting mapping: com.isomorphic.examples.server.queuing.User
      === 2019-09-27 13:50:59,910 [ec-3] DEBUG HibernateDSGenerator - Generating data source 'queuing_userHB' for entity com.isomorphic.examples.server.queuing.User
      === 2019-09-27 13:50:59,910 [ec-3] DEBUG HibernateDSGenerator - Generated data source configuration: {allowAdvancedCriteria=true, dropExtraFields=true, beanClassName=com.isomorphic.examples.server.queuing.User, ID=queuing_userHB, fields=[{extScale=2, hidden=true, primaryKey=true, extIsUnique=false, name=userID, length=255, extIsLazy=false, extPrecision=19, canEdit=false, required=false, type=sequence}, {extScale=2, extIsUnique=false, name=firstName, length=255, extIsLazy=false, extPrecision=19, canEdit=true, required=false, type=text}, {extScale=2, extIsUnique=false, name=surname, length=255, extIsLazy=false, extPrecision=19, canEdit=true, required=false, type=text}, {extScale=2, extIsUnique=false, name=department, length=255, extIsLazy=false, extPrecision=19, canEdit=true, required=false, type=text}, {extScale=2, extIsUnique=false, name=email, length=255, extIsLazy=false, extPrecision=19, canEdit=true, required=false, type=text}], generatedBy=SNAPSHOT_v12.1d_2019-09-27/Enterprise Deployment 2019-09-27, entityName=com.isomorphic.examples.server.queuing.User, serverType=hibernate}
      === 2019-09-27 13:50:59,911 [ec-3] DEBUG RPCManager - Request #1 (DSRequest) payload: {
          values:{
              email:"kamirov@server.com"
          },
          operationConfig:{
              dataSource:"queuing_userHB",
              repo:null,
              operationType:"validate",
              textMatchStyle:"exact"
          },
          validationMode:"partial",
          appID:"builtinApplication",
          operation:"queuing_userHB_validate",
          oldValues:{
              email:"kamirov@server.com"
          },
          criteria:{
          }
      }
      === 2019-09-27 13:50:59,911 [ec-3] INFO  IDACall - Performing 1 operation(s)
      === 2019-09-27 13:50:59,911 [ec-3] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
      === 2019-09-27 13:50:59,911 [ec-3] DEBUG DeclarativeSecurity - DataSource queuing_userHB is not in the pre-checked list, processing...
      === 2019-09-27 13:50:59,911 [ec-3] DEBUG AppBase - No userTypes defined, allowing anyone access to all operations for this application
      === 2019-09-27 13:50:59,911 [ec-3] DEBUG AppBase - No public zero-argument method named '_null' found, performing generic datasource operation
      === 2019-09-27 13:50:59,912 [ec-3] INFO  HB4Provider - Getting mapping: com.isomorphic.examples.server.queuing.User
      === 2019-09-27 13:50:59,912 [ec-3] INFO  HB4Provider - Getting mapping: com.isomorphic.examples.server.queuing.User
      === 2019-09-27 13:50:59,913 [ec-3] DEBUG HibernateDSGenerator - Generating data source 'queuing_userHB' for entity com.isomorphic.examples.server.queuing.User
      === 2019-09-27 13:50:59,920 [ec-3] DEBUG HibernateDSGenerator - Generated data source configuration: {allowAdvancedCriteria=true, dropExtraFields=true, beanClassName=com.isomorphic.examples.server.queuing.User, ID=queuing_userHB, fields=[{extScale=2, hidden=true, primaryKey=true, extIsUnique=false, name=userID, length=255, extIsLazy=false, extPrecision=19, canEdit=false, required=false, type=sequence}, {extScale=2, extIsUnique=false, name=firstName, length=255, extIsLazy=false, extPrecision=19, canEdit=true, required=false, type=text}, {extScale=2, extIsUnique=false, name=surname, length=255, extIsLazy=false, extPrecision=19, canEdit=true, required=false, type=text}, {extScale=2, extIsUnique=false, name=department, length=255, extIsLazy=false, extPrecision=19, canEdit=true, required=false, type=text}, {extScale=2, extIsUnique=false, name=email, length=255, extIsLazy=false, extPrecision=19, canEdit=true, required=false, type=text}], generatedBy=SNAPSHOT_v12.1d_2019-09-27/Enterprise Deployment 2019-09-27, entityName=com.isomorphic.examples.server.queuing.User, serverType=hibernate}
      === 2019-09-27 13:50:59,920 [ec-3] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
      === 2019-09-27 13:50:59,920 [ec-3] DEBUG DeclarativeSecurity - Request is not a client request, ignoring security checks.
      === 2019-09-27 13:50:59,920 [ec-3] DEBUG AppBase - No userTypes defined, allowing anyone access to all operations for this application
      === 2019-09-27 13:50:59,920 [ec-1] INFO  RequestContext - URL: '/isomorphic/skins/Tahoe/images/actions/remove.png', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36': Safari with Accept-Encoding header
      === 2019-09-27 13:50:59,921 [ec-3] DEBUG AppBase - No public zero-argument method named '_null' found, performing generic datasource operation
      === 2019-09-27 13:50:59,921 [ec-3] INFO  HibernateDataSource - Performing fetch operation with
          outputs: [userID, email]    criteria: {email:"kamirov@server.com"}    values: {email:"kamirov@server.com"}
      === 2019-09-27 13:50:59,921 [ec-3] INFO  HB4Provider - Getting factory
      === 2019-09-27 13:50:59,921 [ec-3] DEBUG SQLConnectionManager - Borrowed connection '4465026'
      === 2019-09-27 13:50:59,922 [ec-3] DEBUG HibernateTransaction - Started new transaction "446369964"
      === 2019-09-27 13:50:59,922 [ec-3] INFO  HibernateDataSource - Query string: select _User.userID as userID, _User.email as email from com.isomorphic.examples.server.queuing.User _User  where (lower(_User.email) = lower(:p0))
      === 2019-09-27 13:50:59,922 [ec-3] DEBUG HibernateDataSource - Parameter p0: kamirov@server.com
      === 2019-09-27 13:50:59,922 [ec-3] DEBUG SQL - 
          select
              user0_.userID as col_0_0_,
              user0_.email as col_1_0_ 
          from
              queuing_user user0_ 
          where
              lower(user0_.email)=lower(?)
      === 2019-09-27 13:50:59,924 [ec-3] INFO  HibernateTransaction - Attempting to commit 0 database update(s)
      === 2019-09-27 13:50:59,924 [ec-3] DEBUG HibernateTransaction - Committing transaction "446369964"
      === 2019-09-27 13:50:59,925 [ec-3] INFO  DSResponse - DSResponse: List with 1 items
      === 2019-09-27 13:50:59,925 [ec-3] DEBUG DefaultValidators - unique check: pkField: userID, old PK: 1, new PK: null
      === 2019-09-27 13:50:59,925 [ec-3] DEBUG DefaultValidators - unique check: key fields do not match, fails unique check
      === 2019-09-27 13:50:59,926 [ec-3] DEBUG ValidationContext - Adding validation errors at path '/queuing_userHB/email/email': {errorMessage=Value must be unique}
      === 2019-09-27 13:50:59,926 [ec-3] INFO  Validation - Validation error: [
          {
              email:{
                  errorMessage:"Value must be unique"
              }
          }
      ]
      === 2019-09-27 13:50:59,927 [ec-3] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
      === 2019-09-27 13:50:59,927 [ec-3] WARN  HibernateTransaction - Attempted to commit null transaction
      === 2019-09-27 13:50:59,927 [ec-3] WARN  HibernateTransaction - Attempted to commit null transaction
      === 2019-09-27 13:50:59,927 [ec-3] DEBUG RPCManager - non-DMI response, dropExtraFields: false
      === 2019-09-27 13:50:59,928 [ec-3] DEBUG HibernateTransaction - Closing session "446369964"
      === 2019-09-27 13:50:59,928 [ec-3] DEBUG HibernateTransaction - Removed transaction "446369964"
      === 2019-09-27 13:50:59,928 [ec-3] INFO  Compression - /isomorphic/IDACall: 218 -> 180 bytes
      === 2019-09-27 13:50:59,943 [ec-2] INFO  RequestContext - URL: '/isomorphic/skins/Tahoe/images/actions/exclamation.png', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36': Safari with Accept-Encoding header
      === 2019-09-27 13:50:59,951 [ec-6] INFO  RequestContext - URL: '/isomorphic/skins/Tahoe/images/blank.gif', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36': Safari with Accept-Encoding header
      === 2019-09-27 13:51:00,397 [ec-7] INFO  RequestContext - URL: '/isomorphic/skins/Tahoe/images/ListGrid/sort_descending.png', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36': Safari with Accept-Encoding header
      === 2019-09-27 13:51:00,411 [ec-9] INFO  RequestContext - URL: '/isomorphic/skins/Tahoe/images/actions/view.png', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36': Safari with Accept-Encoding header
      === 2019-09-27 13:51:00,411 [ec-5] INFO  RequestContext - URL: '/isomorphic/skins/Tahoe/images/actions/close.png', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36': Safari with Accept-Encoding header
      === 2019-09-27 13:51:00,415 [c-10] INFO  RequestContext - URL: '/isomorphic/skins/Tahoe/images/blank.gif', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36': Safari with Accept-Encoding header

      Comment


        #4
        Thanks for the test case. We're taking a look

        Regards
        Isomorphic Software

        Comment


          #5
          We've made a change to address this issue.
          Please try the next nightly 12.1d build (dated Oct 2 or above)

          Regards
          Isomorphic Software

          Comment

          Working...
          X