Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: [OPEN-1039] JsonReader bug in 3.2.1 that affects Ext.data.ArrayStore

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #11
    Ext JS Premium Member
    Join Date
    Jul 2009
    Posts
    27

    Default

    @Jamie: Yes, I guess I was overreacting a bit, because I found Ext forum tend to be less helpful than professional/premium quality, precisely because of a dismissive or "it's a feature not bug" or "you're not using it the right way" attitude when a bug was found. Many threads, including a bit in this one, demonstrated this issue.

    @evant: Code in OP uses Ext.data.ArrayStore, there's no requirement that the columns be database fields. AFAIK, people use ArrayStore with all sorts of DBMS-columnname-incompatible characters.

    @condor: I agree, when I tracked down the issue with the ArrayStore example to JsonReader, I felt it was strange too. I don't intend to use JsonReader at all in this case, so certainly I agree that it's best that ArrayStore does not use JsonReader's methods by default.

    @animal: The fix you proposed is ONE of the many fixes, but it is far from the CORRECT fix. Firstly, it doesn't address the fact that the code in OP works fine for 3.1.x but not 3.2.x. Your proposal would demand all clients rewrite their code that uses ArrayStore. 2nd, there's no documentation indicating that when certain special characters exist in ArrayStore field names, one needs to specify mapping (to avoid calling a buggy function). 3rd, shouldn't the mapping done automatically by Ext code when it sees special characters (or by default)?

    I'm fine with whichever fix you guys come up with, as long as it doesn't demand users to rewrite their 3.1.x-compatible code. As I said, so far I'm happy with just overriding the 3.2.x code (of createAccessor) with the 3.1.x counterpart.

  2. #12
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    If truth be told, it should ot have worked in 3.1

    JsonReader <-> ArrayStore

    Mismatch.

  3. #13
    Sencha User
    Join Date
    Mar 2010
    Location
    Baltimore, MD
    Posts
    33

    Default

    We are having a similar problem with JsonReader itself that it does not allow dots (.) in field names when pared with a grid. Our solution was based on this thread with a try catch block. The fix appears below but is obviously temporary:
    Code:
    Ext.override(Ext.data.JsonReader, {
      createAccessor : function(){
            var re = /[\[\.]/;
            return function(expr) {
                if(Ext.isEmpty(expr)){
                    return Ext.emptyFn;
                }
                if(Ext.isFunction(expr)){
                    return expr;
                }
    	    // start modified code
    	    try {
                	var i = String(expr).search(re);
                	if(i >= 0){
                    	return new Function('obj', 'return obj' + (i > 0 ? '.' : '') + expr);
                    }
    	} catch(e) {
    	       return function(obj){
        	            return obj[expr];
            	};
    	}
    	// end of modified code 
                return function(obj){
                    return obj[expr];
                };
            };
        }()
    });

  4. #14
    Sencha User
    Join Date
    Mar 2010
    Location
    Baltimore, MD
    Posts
    33

    Default

    We are having a similar problem with JsonReader itself that it does not allow dots (.) in field names when pared with a grid. Our solution was based on this thread with a try catch block. The fix appears below but is obviously temporary:
    Code:
    Ext.override(Ext.data.JsonReader, {
      createAccessor : function(){
            var re = /[\[\.]/;
            return function(expr) {
                if(Ext.isEmpty(expr)){
                    return Ext.emptyFn;
                }
                if(Ext.isFunction(expr)){
                    return expr;
                }
    	    // start modified code
    	    try {
                	var i = String(expr).search(re);
                	if(i >= 0){
                    	return new Function('obj', 'return obj' + (i > 0 ? '.' : '') + expr);
                    }
    	} catch(e) {
    	       return function(obj){
        	            return obj[expr];
            	};
    	}
    	// end of modified code 
                return function(obj){
                    return obj[expr];
                };
            };
        }()
    });

  5. #15
    Sencha User
    Join Date
    Mar 2010
    Location
    Baltimore, MD
    Posts
    33

    Default

    I would also add regarding the comment above that it is possible to have all kinds of characters in database column names, even periods. For example, in SQL Server, as long as everything is escaped properly, any character is fine.

  6. #16
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Why do you insist on trying to patch createAccessor to fix this problem? createAccessor isn't the problem!

    The problem is that ArrayReader uses JsonReader.buildExtractors and JsonReader.extractValues, which you can simply fix with:
    Code:
    Ext.override(Ext.data.ArrayReader, {
      buildExtractors: Ext.emptyFn,
      extractValues: Ext.emptyFn
    });

  7. #17
    Sencha User
    Join Date
    Mar 2010
    Location
    Baltimore, MD
    Posts
    33

    Default

    Quote Originally Posted by Condor View Post
    Why do you insist on trying to patch createAccessor to fix this problem? createAccessor isn't the problem!

    The problem is that ArrayReader uses JsonReader.buildExtractors and JsonReader.extractValues
    ...
    Because my problem is not in ArrayReader. Rather, I am having issues with JsonReader itself reading Json data from the server with field names containing periods. Should I file this as a separate bug?

  8. #18
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    You don't need to patch createAccessor for that either!

    Simply specify a mapping, e.g.
    Code:
    {name: 'abc_def', mapping: '["abc.def"]'}
    or
    Code:
    {name: 'abc_def', mapping: function(v){ return v['abc.def'];}}

  9. #19
    Sencha User
    Join Date
    Mar 2010
    Location
    Baltimore, MD
    Posts
    33

    Default

    That still does not resolve the problem with the library itself that it does not handle periods properly

  10. #20
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    What do you mean by 'proper'? The '.' in a mapping normally means 'nested object', e.g. {"abc": {"def": 123}}.

    If you want to use JsonReader to read properties with '.' in the name then you will have to use a mapping, because it isn't covered by the default behaviour.

    Using '.' in a name is not advisable anyway, because you can only access the property using ['name'] notation.

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Bug in Ext.data.JsonReader?
    By mainmanmauricio in forum Ext 3.x: Help & Discussion
    Replies: 7
    Last Post: 22 Nov 2012, 3:35 AM
  2. Replies: 1
    Last Post: 18 Mar 2010, 12:44 PM
  3. [OPEN-58][3.0+] JsonReader with array data
    By Condor in forum Ext 3.x: Bugs
    Replies: 8
    Last Post: 20 Oct 2009, 2:43 AM
  4. [2.0] Firefox bug affects data.xmlReader
    By Gribnif in forum Ext 2.x: Bugs
    Replies: 0
    Last Post: 30 Jan 2008, 7:40 AM
  5. Ext.data.connection method is case sensitive (affects paged grid)
    By corey.gilmore in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 4 Apr 2007, 2:51 PM

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
  •