You found a bug! We've classified it as TOUCH-2771 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    23
    Vote Rating
    5
    jamezilla is on a distinguished road

      2  

    Default autloaded associations don't properly filter data from a JSON proxy

    autloaded associations don't properly filter data from a JSON proxy


    REQUIRED INFORMATION

    Ext version tested:
    • Sencha 2.0.1rc
    Browser versions tested against:
    • Chrome 18.0.1025.162 (OS X)
    DOCTYPE tested against:
    • <!DOCTYPE HTML>
    Description:
    • HasMany associations with the autoLoad config set to true, don't properly filter data coming from a JSON proxy, even when the data includes the proper foreign key. An associated store which contains 12 items will assign all 12 items to each instance of the owner model regardless of whether foreign key attributes in the JSON.
    Steps to reproduce the problem:
    • create a store for an associated model, with a JSON proxy to load data
    • create a store for an owner model, set the associated model as a hasMany association with autoLoad set to true for the association
    • load an instance of the owner model
    The result that was expected:
    • the owner model instance should only contain the associated model instances which had the owner model id as a foreign key in the original JSON
    The result that occurs instead:
    • the owner model instance contains all the associated model instances from the original JSON, whether or not the foreign key in the JSON matches the owner model
    • the foreign key values of all the associated model instances have been overwritten with the owner model instance's foreign key
    • look at the console output from the load listener in the test case: notice that both Venue instances contain all of the Image models from the JSON, rather than just the images that belong to them.
    Test Case:

    Full Github repo here:http://github.com/jamezilla/sencha-associations-test

    Code:
    // venues.json
    [
        {"id":156, "name":"Artusi"},
        {"id":157, "name":"Ba Bar"},
        {"id":158, "name":"Baltic Room"},
        {"id":159, "name":"Bar Ferd'nand"},
        {"id":160, "name":"Barca"}
    ]
    
    
    // images.json
    [
        {"caption":"Caption 1", "id":21, "venue_id":156},
        {"caption":"Caption 2", "id":22, "venue_id":156},
        {"caption":"Caption 3", "id":23, "venue_id":156},
        {"caption":"Caption 4", "id":24, "venue_id":157},
        {"caption":"Caption 5", "id":25, "venue_id":157},
        {"caption":"Caption 6", "id":26, "venue_id":157},
        {"caption":"Caption 7", "id":27, "venue_id":158},
        {"caption":"Caption 8", "id":28, "venue_id":158},
        {"caption":"Caption 9", "id":29, "venue_id":158},
        {"caption":"Caption 0", "id":30, "venue_id":159},
        {"caption":"Caption A", "id":31, "venue_id":159},
        {"caption":"Caption B", "id":32, "venue_id":159}
    ]
    
    
    // Venue
    
    
    Ext.define('MyApp.model.Venue', {
        extend: 'Ext.data.Model',
        require: [
            'MyApp.model.Image'
        ],    
        config: {
            proxy: {
                type:   'ajax',
                url:    'venues.json',
                reader: 'json'
            },
            fields: [
                {name: 'id',   type: 'int'},
                {name: 'name', type: 'string'}
            ],
            hasMany: [
                {
                    associatedModel:'MyApp.model.Image',
                    autoLoad: true
                }
            ]
        }
    });
    
    
    Ext.define('MyApp.store.Venues', {
        extend: 'Ext.data.Store', 
        config: {
            autoLoad: true,
            model: 'MyApp.model.Venue',
            storeId: 'VenuesStore',
            listeners : {
                load : function(store) {
                    console.log(store.getAt(0).images().data);
                    console.log(store.getAt(1).images().data);
                }
            }
        }
    });
    
    
    Ext.define('MyApp.model.Image', {
        extend: 'Ext.data.Model',
        config: {
            proxy: {
                type:   'ajax',
                url :   'images.json',
                reader: 'json'
            },
            fields: [
                {name: 'id',      type: 'int'},
                {name: 'caption', type: 'string'},
                {name: 'venue_id', type: 'int'}
            ]
        }
    });
    
    
    Ext.define('MyApp.store.Images', {
        extend: 'Ext.data.Store', 
        config: {
            model: 'MyApp.model.Image',
            storeId: 'ImagesStore',
            listeners: {
                load: function(store) {
                    console.log("Loaded ImagesStore");
                }
            }
    
    
    
    
        }
    });
    HELPFUL INFORMATION

    Operating System:
    • OS X 10.7.3

  2. #2

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    23
    Vote Rating
    5
    jamezilla is on a distinguished road

      0  

    Default bump

    bump


    Is there some reason this bug isn't getting any attention? I'm happy to update it if there's something wrong with the quality or format of the bug report.

  4. #4
    Sencha User zigguratt's Avatar
    Join Date
    Sep 2010
    Location
    Toronto, Canada
    Posts
    17
    Vote Rating
    0
    zigguratt is on a distinguished road

      0  

    Default


    I'm wondering the same thing myself. It seems to be a rather large defect in the model/store system: associations in this situation are completely unusable. Luckily for me, my project is currently a proof of concept so I can actually fake the parts that are defective, though I would have loved to present a more functional prototype.

    I do realize that this stuff is all pretty new, and I greatly appreciate the effort that has gone into this system. I would love to recommend it to my team here, but until basics like database associations are working, I can't do that. Hopefully this will be resolved before I have to present my PoC.

  5. #5
    Sencha - Sencha Touch Dev Team Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    20
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    Thank you for the report.

    Sencha Inc

    Jamie Avins

    @jamieavins

  6. #6
    Sencha User zigguratt's Avatar
    Join Date
    Sep 2010
    Location
    Toronto, Canada
    Posts
    17
    Vote Rating
    0
    zigguratt is on a distinguished road

      0  

    Default


    Any updates on this bug?

  7. #7
    Sencha User
    Join Date
    Apr 2012
    Posts
    1
    Vote Rating
    0
    yeetender is on a distinguished road

      0  

    Default same problem with xml

    same problem with xml


    I am also facing the same problem while loading data from xml file. It doesn't filter the associated record rather shows all records.

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