Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default [OPEN-280] WebStorageProxy#getIds() returns an array of strings, not integers

    [OPEN-280] WebStorageProxy#getIds() returns an array of strings, not integers


    In Sencha Touch 0.94, WebStorageProxy#getIds() returns an array of strings, while Model#getId() returns a Number.

    this causes WebStorageProxy#destroy() to fail because the following line
    Code:
    newIds.remove(records[i].getId());
    will never remove the numeric id from the array of string ids.

    possible fix:
    Code:
        destroy: function(operation, callback, scope) {
            var records = operation.records,
                length  = records.length,
                ids     = this.getIds(),
    
    
                newIds  = [].concat(ids),
                i;
    
            for (i = 0; i < length; i++) {
                newIds.remove(records[i].getId() + '');
                this.removeRecord(records[i], false);
            }
    
            this.setIds(newIds);
    
            if (typeof callback == 'function') {
                callback.call(scope || this, operation);
            }
        },

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,181
    Vote Rating
    119
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Thx for the report. Dup of #280.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    i tried searching for OPEN-280 (and getIds() for the matter), but this is the only thread marked [OPEN-280].
    do you have a link of the original bugreport on hand?

  4. #4
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,181
    Vote Rating
    119
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Marc - There is no forum thread on it. We opened the ticket internally.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  5. #5
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    7
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    I've updated WebStorageProxy to cast each id returned by getIds() into a number. This will be present in the next build.
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  6. #6
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    super. thanks!

  7. #7
    Sencha User
    Join Date
    May 2011
    Location
    San Francisco
    Posts
    7
    Vote Rating
    0
    holdenmatt is on a distinguished road

      0  

    Default


    This fix seems to have created a new bug:

    WebStorageProxy#getIds() is now always returning an array of ints, but Model#getId() will return a string when a model has an "id" field of type string (e.g. the default type).

    This makes WebStorageProxy#destroy fail since
    newIds.remove(records[i].getId());
    tries to remove a string from an array of ints, and so never removes anything.

  8. #8
    Sencha User
    Join Date
    May 2011
    Location
    San Francisco
    Posts
    7
    Vote Rating
    0
    holdenmatt is on a distinguished road

      0  

    Default


    If you're using string ids for your Models (as I am), here's a workaround to fix this:

    Code:
        Ext.override(Ext.data.WebStorageProxy, {
            /**
             * Make getIds() return an array of strings instead of ints.
             */
            getIds: function() {
                var ids = (this.getStorageObject().getItem(this.id) || "").split(",");
                if (ids.length == 1 && ids[0] == "") {
                    ids = [];
                }
                return ids;
            }
        });
    This fixes my problem, but WebStorageProxy should probably be fixed to work with either string or int ids, e.g. by:
    - removing the parseInt loop from getIds, and
    - casting model ids to strings before making comparisons

  9. #9
    Sencha User Mis63's Avatar
    Join Date
    Aug 2010
    Location
    Clermont-Ferrand, France
    Posts
    42
    Vote Rating
    0
    Mis63 is on a distinguished road

      0  

    Default


    WebStorageProxy has many bugs and/or limitations (string key, associations reading/writing...) and I think that it should be a priority for next release.

    About this thread : to do working it in all cases (numeric and string keys), the id should be converted to int only if the key of model is a numeric.

    Code:
    getIds: function() {
            var ids    = (this.getStorageObject().getItem(this.id) || "").split(","),
                length = ids.length,
                i;
    
            if (length == 1 && ids[0] == "") {
                ids = [];
            } else {
                if (<key of model is numeric>) {
                   for (i = 0; i < length; i++) {
                       ids[i] = parseInt(ids[i], 10);
                   }
               }
            }
    
            return ids;
        }
    }

    How to write the test ? Any idea ?

  10. #10
    Sencha User Mis63's Avatar
    Join Date
    Aug 2010
    Location
    Clermont-Ferrand, France
    Posts
    42
    Vote Rating
    0
    Mis63 is on a distinguished road

      0  

    Default


    A test could be :
    Code:
    getIds: function() {
      var ids = (this.getStorageObject().getItem(this.id) || "").split(","),
           length = ids.length,
           i;
      if (length == 1 && ids[0] == "") {
        ids = [];
      } else {
        for (i = 0; i < length; i++) {
          if (!isNaN(ids[i])) {
            ids[i] = parseInt(ids[i], 10);
          }
        }
      }
      return ids;
    }
    It works but it is not optimized as :
    1. test is done for each id (inside for loop)
    2. it does not check datatype of model's id

Similar Threads

  1. [OPEN-257] WebStorageProxy always removes first record
    By emm in forum Sencha Touch 1.x: Bugs
    Replies: 2
    Last Post: 15 Sep 2010, 8:39 PM
  2. Combobox with array returns text instead of value
    By zvucini in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 4 Oct 2008, 3:52 PM
  3. Store collection returns empty array
    By Padster in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 18 Sep 2008, 9:11 AM
  4. Replies: 1
    Last Post: 22 Jun 2007, 9:10 AM
  5. Make Date.parseDate accept an array of possible format strings
    By corey.gilmore in forum Community Discussion
    Replies: 2
    Last Post: 30 May 2007, 5:51 PM

Thread Participants: 5

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi