Hybrid View

    You found a bug! We've classified it as TOUCH-3395 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User Dumas's Avatar
    Join Date
    Dec 2008
    Location
    Vienna, Austria
    Posts
    581
    Vote Rating
    9
    Dumas will become famous soon enough

      0  

    Default Writer::writeDate bug for allowNull

    Writer::writeDate bug for allowNull


    REQUIRED INFORMATION


    Ext version tested:
    • Chrome 21
    DOCTYPE tested against:
    • not important, this is a straight js error
    Description:
    • Creating a record with a field {type:'date',allowNull:true,defaultValue:null} and no value creates an error in Ext.data.writer.Writer::writeDate, because date is null this line fails:
      return date.getTime()/1000;
    Steps to reproduce the problem:
    • Create a record and save it with null as date value
    The result that was expected:
    • saving of field value null
    The result that occurs instead:
    • javascript error
    Test Case:

    Code:
    Ext.define('MyApp.model.MyModel5', {
        extend: 'Ext.data.Model',
        config: {
            fields: ['id',{name:"nulldate",allowNull:true,defaultValue:null,type:"date"}],
            proxy: {
                type: 'direct', 
                api: {
                    create: MyApp.myDirectStub.create
                },
                writer: {
                    type: 'json',
                    rootProperty: 'data'
                }
            }
        }
    });
    Ext.create('MyApp.model.MyModel5').save();




    HELPFUL INFORMATION

    Debugging already done:
    • yes
    Possible fix:

    Here is a fix everyone call use till Sencha fixed it:
    Code:
     Ext.define('Ext.data.override.Writer', {
        override: 'Ext.data.Writer',
        writeDate: function (field, date) {
            if(date===null || !Ext.isDefined(date)) {
                if(field.getAllowNull()) {
                    return null;
                } else {
                    Ext.Error.raise('SOME ERROR MESSAGE HERE');
                }
            }
            var dateFormat = field.dateFormat || 'timestamp';
            switch (dateFormat) {
                case 'timestamp':
                    return date.getTime()/1000;
                case 'time':
                    return date.getTime();
                default:
                    return Ext.Date.format(date, dateFormat);
            }
        }
    });
    Best regards
    Roland

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Vote Rating
    834
    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


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

  3. #3
    Sencha Premium Member
    Join Date
    May 2011
    Posts
    3
    Vote Rating
    0
    dgjones is on a distinguished road

      0  

    Default A small change to the proposed workaround...

    A small change to the proposed workaround...


    Thanks for the workaround. I found that one line caused an issue for me, so I'd like to suggest an alteration:
    Code:
    var dateFormat = field.getDateFormat() || 'timestamp';
    field.dateFormat returns undefined, so dateFormat is always 'timestamp'.

  4. #4
    Sencha User
    Join Date
    Jul 2012
    Location
    Italy
    Posts
    84
    Vote Rating
    4
    Tegola is on a distinguished road

      0  

    Default


    Thanks, this solved my problems with null dates.
    Looking forward to having this added to Sencha Touch, so I can remove the override.

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