Skip to content

a few bugs: #4

@jacobg

Description

@jacobg
  • Line 339 in the destroy method looks like it should be removed
  • Line 340 looks like the false parameter can be removed (although it causes no harm)
  • setRecord's onSuccess callback should update the record id based on value from database if was not set, as follows:
    setRecord: function(record) {

        var me = this,
            rawData = record.data,
            fields = [],
            values = [],
            placeholders = [],
            onSuccess = function(tx,rs,record) {
                if (me.insertingInitialData) {
                    me.initialDataCount--;
                    if (me.initialDataCount === 0) {
                        me.insertingInitialData = false;
                        me.fireEvent('initialDataInserted');
                    }
                }

                // If record source did not have an id, then that means
                // the database just generated one. So we'll update the
                // record now.
                if(typeof record.get('id') == 'undefined'){
                    record.internalId = rs.insertId;
                    record.data.id = rs.insertId;
                }
            };

        //extract data to be inserted
        for (var i in rawData) {
            fields.push('"'+i+'"');
            values.push(rawData[i]);
            placeholders.push('?');
        }

        me.db.transaction(function(tx){
            tx.executeSql('INSERT INTO ' + me.dbTable+'('+fields.join(',')+') VALUES ('+placeholders.join(',')+')',
                values,
                Ext.bind(onSuccess, me, [record], true),  //on success
                Ext.bind(me.onError, me));        // on error
        });

        return true;
    },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions