Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.
  1. #1
    Sencha User rkraus's Avatar
    Join Date
    Dec 2011
    Location
    Bonn / Germany
    Posts
    68
    Vote Rating
    0
    rkraus is an unknown quantity at this point

      0  

    Default ST2.1 RC2 Crash when new SQL Proxy without "filter"

    ST2.1 RC2 Crash when new SQL Proxy without "filter"


    Hi,

    when I use the new Ext.data.proxy.SQL to save my data I run into:
    • [COLOR=red !important]Uncaught TypeError: Cannot read property 'length' of null SQL.js:268[/COLOR]
      • [COLOR=red !important]Ext.define.selectRecords[/COLOR]SQL.js:268
      • [COLOR=red !important](anonymous function)[/COLOR]SQL.js:108
    Greetings -Ralf Kraus-

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,217
    Vote Rating
    859
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Can I get a locally runnable test case to reproduce?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Location
    Germany
    Posts
    146
    Vote Rating
    10
    Möhre will become famous soon enough

      0  

  4. #4
    Sencha User rkraus's Avatar
    Join Date
    Dec 2011
    Location
    Bonn / Germany
    Posts
    68
    Vote Rating
    0
    rkraus is an unknown quantity at this point

      0  

    Default


    Will this patch be in the next nightly build?
    Greetings -Ralf Kraus-

  5. #5
    Sencha User rkraus's Avatar
    Join Date
    Dec 2011
    Location
    Bonn / Germany
    Posts
    68
    Vote Rating
    0
    rkraus is an unknown quantity at this point

      0  

    Default


    Hi,

    It won´t fix my problem...

    I have problems with line 268 !

    Code:
    ln = params.filters.length;
    When there are no filters setup in the proxy config...
    Greetings -Ralf Kraus-

  6. #6
    Sencha User rkraus's Avatar
    Join Date
    Dec 2011
    Location
    Bonn / Germany
    Posts
    68
    Vote Rating
    0
    rkraus is an unknown quantity at this point

      0  

    Default


    I fixed it....

    Code:
    Index: touch/src/data/proxy/SQL.js===================================================================
    --- touch/src/data/proxy/SQL.js	(revision 6988)
    +++ touch/src/data/proxy/SQL.js	(working copy)
    @@ -110,23 +110,25 @@
                         me.fireEvent('exception', me, operation);
                     }
     
    -                if (filters.length) {
    -                    filtered = Ext.create('Ext.util.Collection', function(record) {
    -                        return record.getId();
    -                    });
    -                    filtered.setFilterRoot('data');
    -                    for (i = 0, ln = filters.length; i < ln; i++) {
    -                        if (filters[i].getProperty() === null) {
    -                            filtered.addFilter(filters[i]);
    -                        }
    -                    }
    -                    filtered.addAll(operation.getRecords());
    +								if (params.sorters != null) {
    +									if (filters.length) {
    +											filtered = Ext.create('Ext.util.Collection', function(record) {
    +													return record.getId();
    +											});
    +											filtered.setFilterRoot('data');
    +											for (i = 0, ln = filters.length; i < ln; i++) {
    +													if (filters[i].getProperty() === null) {
    +															filtered.addFilter(filters[i]);
    +													}
    +											}
    +											filtered.addAll(operation.getRecords());
     
    -                    operation.setRecords(filtered.items.slice());
    -                    resultSet.setRecords(operation.getRecords());
    -                    resultSet.setCount(filtered.items.length);
    -                    resultSet.setTotal(filtered.items.length);
    -                }
    +											operation.setRecords(filtered.items.slice());
    +											resultSet.setRecords(operation.getRecords());
    +											resultSet.setCount(filtered.items.length);
    +											resultSet.setTotal(filtered.items.length);
    +									}
    +								}
     
                     if (typeof callback == 'function') {
                         callback.call(scope || me, operation);
    @@ -265,35 +267,40 @@
             if (!Ext.isObject(params)) {
                 sql += filterStatement + idProperty + ' = ' + params;
             } else {
    -            ln = params.filters.length;
    -            if (ln) {
    -                for (i = 0; i < ln; i++) {
    -                    filter = params.filters[i];
    -                    property = filter.getProperty();
    -                    value = filter.getValue();
    -                    if (property !== null) {
    -                        sql += filterStatement + property + ' ' + (filter.anyMatch ? ('LIKE \'%' + value + '%\'') : ('= \'' + value + '\''));
    -                        filterStatement = ' AND ';
    -                    }
    -                }
    -            }
     
    -            ln = params.sorters.length;
    -            if (ln) {
    -                for (i = 0; i < ln; i++) {
    -                    sorter = params.sorters[i];
    -                    property = sorter.getProperty();
    -                    if (property !== null) {
    -                        sql += sortStatement + property + ' ' + sorter.getDirection();
    -                        sortStatement = ', ';
    -                    }
    -                }
    -            }
    +					if (params.sorters != null) {
    +						ln = params.sorters.length;
    +						if (ln) {
    +							for (i = 0; i < ln; i++) {
    +								sorter = params.sorters[i];
    +								property = sorter.getProperty();
    +								if (property !== null) {
    +									sql += sortStatement + property + ' ' + sorter.getDirection();
    +									sortStatement = ', ';
    +								}
    +							}
    +						}
    +					}
     
    -            // handle start, limit, sort, filter and group params
    -            if (params.page !== undefined) {
    -                sql += ' LIMIT ' + parseInt(params.start, 10) + ', ' + parseInt(params.limit, 10);
    -            }
    +					if (params.filters != null) {
    +						ln = params.filters.length;
    +						if (ln) {
    +							for (i = 0; i < ln; i++) {
    +								filter = params.filters[i];
    +								property = filter.getProperty();
    +								value = filter.getValue();
    +								if (property !== null) {
    +									sql += filterStatement + property + ' ' + (filter.getAnyMatch() ? ('LIKE \'%' + value + '%\'') : ('= \'' + value + '\''));
    +									filterStatement = ' AND ';
    +								}
    +							}
    +						}
    +					}
    +
    +					// handle start, limit, sort, filter and group params
    +					if (params.page !== undefined) {
    +							sql += ' LIMIT ' + parseInt(params.start, 10) + ', ' + parseInt(params.limit, 10);
    +					}
             }
     
             transaction.executeSql(sql, null,
    Greetings -Ralf Kraus-

Thread Participants: 2