Results 1 to 9 of 9

Thread: Ext.data.Session ignores proxy batchActions setting

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-20025 in 6.2.2.
  1. #1
    Sencha User
    Join Date
    Jan 2008
    Posts
    26

    Default Ext.data.Session ignores proxy batchActions setting

    Ext version tested:
    • Ext 5.1.1.451



    Description:
    • Ext.data.Session getSaveBatch method does not consult the relevant Proxy's batchActions config and always sends multiple records update as an array to the server.



    Cause of the problem:
    This is an excerpt from the BatchVisitor code:
    PHP Code:
    proxy entity.getProxy();

    delete bucket.entity// so we don't think its an operation
    for (operation in bucket) {
        
    operation proxy.createOperation(operation, {
            
    recordsbucket[operation]
        });
        
    operation.entityType entity;

        
    batch.add(operation);

    As you can see, an operation is always created with multiple records.
    Instead the code should consult the proxy for the correct behavior:

    PHP Code:


    proxy 
    entity.getProxy();

    delete bucket.entity// so we don't think its an operation
    for (operation in bucket) {
        if (
    proxy.getBatchActions()) { // Consult the proxy settings!
            
    operation proxy.createOperation(operation, {
                
    recordsbucket[operation]
            });
            
    operation.entityType entity;

            
    batch.add(operation);        
        } else { 
    // No batch allowed. Create operations for every record.
            
    var rLen bucket[operation].length;

            for (
    0rLenr++) {
                
    record bucket[operation][r];

                
    batch.add(proxy.createOperation(operation, {records : [record]}));
            }
        }


  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the report. Can you please post a test case which reproduces this issue?
    https://fiddle.sencha.com/#home

  3. #3
    Sencha User
    Join Date
    Jan 2008
    Posts
    26

    Default

    What exactly can I illustrate by a fiddle in this case?
    You need to have a REST server for an example to be useful, so you could see the data being transferred to the server.
    You can refer to the code of Ext.data.Proxy to see how it uses batchActions config and compare it to the code from BatchVisitor to see that it does not care if this config is set or not and thus prevents using session save on some REST servers that demand records being sent one by one instead of an array.

  4. #4
    Sencha User
    Join Date
    Jan 2008
    Posts
    26

    Default

    Anyway, here's a fiddle. I had some spare time and created it.
    To see the problem though you need to watch XHR requests payload this fiddle makes when saving via store.sync() or session.getSaveBatch().start().
    You will see that save via session makes one request to the server while save via store makes two requests - one per changed record.


  5. #5
    Sencha User
    Join Date
    Jan 2008
    Posts
    26

    Default

    Please review this report again. This is not an info request, it is a serious bug as far as I'm concerned.

  6. #6
    Sencha Premium Member
    Join Date
    Nov 2010
    Posts
    53

    Default Solved

    Confirm, same issue.
    Here is a workaround

    Code:
    Ext.define('Ext.bf.data.session.BatchVisitor', {
        override: 'Ext.data.session.BatchVisitor',
        
        getBatch: function (sort) {
            var map = this.map,
                batch = this.batch,
                bucket, entity, name, operation, proxy,
                action, records, r, rLen, useBatch;
    
            if (map) {
                if (!batch) {
                    batch = new Ext.data.Batch();
                }
                for (name in map) {
                    bucket = map[name];
                    entity = bucket.entity;
                    // the entity class
                    proxy = entity.getProxy();
                    useBatch = proxy.getBatchActions();
                    delete bucket.entity;
                    // so we don't think its an operation
                    for (action in bucket) {
                        records = bucket[action];
                        rLen = records.length;
    
                        if (useBatch) {
                            operation = proxy.createOperation(action, {
                                records: records
                            });
                            operation.entityType = entity;
                            batch.add(operation);
                        }
                        else {
                            for (r = 0; r < rLen; r++) {
                                record = records[r];
    
                                operation = proxy.createOperation(action, {
                                    records: [record]
                                });
                                operation.entityType = entity;
                                batch.add(operation);
                            }
                        }
                    }
                }
            }
    
    
            if (batch && sort !== false) {
                batch.sort();
            }
            return batch;
        }
    });

  7. #7
    Sencha User
    Join Date
    Jan 2008
    Posts
    26

    Default

    Yes, that's the same workaround I submitted in the original post. Sencha guys don't seem to care though.

  8. #8
    Sencha Premium Member
    Join Date
    Nov 2010
    Posts
    53

    Default

    Oh, yes, I missed it. It's sad that they don't pay attention for such a detailed bugreports like this one. Hope they will fix it someday considering workaround code is easy.

  9. #9
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

Similar Threads

  1. Replies: 6
    Last Post: 27 Jul 2016, 10:29 AM
  2. Updating Session data on proxy load
    By The0s in forum Ext 5: Q&A
    Replies: 0
    Last Post: 4 Feb 2015, 9:19 AM
  3. Replies: 4
    Last Post: 26 Jan 2015, 1:25 AM
  4. batchActions on Rest Proxy with single record
    By ShaneTex in forum Sencha Touch 2.x: Q&A
    Replies: 3
    Last Post: 22 Nov 2012, 11:08 AM
  5. [CLOSED] Ext.data.proxy.Direct - extraParams ignores changes in scope?
    By el.weilando in forum Ext:Bugs
    Replies: 1
    Last Post: 25 Aug 2011, 10:51 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •