GithubHelp home page GithubHelp logo

ext.data.websqlproxy's People

Contributors

lisimba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ext.data.websqlproxy's Issues

updateRecord doesn't work with Sencha 1.1.1

I changed updateRecord because id = record.internalId || record[me.pkField] was turning up undefined, as were modifiedData = record.modified and newData = record.data.

I modified the id variable to:

id = record.internalId || record[me.pkField] || record.data[me.pkField],

I changed the pairs and values initialization to:

/*for (var i in modifiedData) {
    pairs.push('"'+i+'" = ?');
    values.push(newData[i]);
}*/
var fields = Object.keys(record.data);
for (var i=0; i<fields.length; i++) {
    var field = fields[i];
    if (key == field) {
        // Don't want to update primary key
        continue;
    }
    pairs.push(field + ' = ?');
    values.push(record.data[field]);
}
values.push(id);

removeRecord parameter is wrong

The removeRecord function says it takes an ID as a parameter, but using Chrome's debugger and Sencha Touch 1.1.1, what actually gets passed is the record itself (an instance of Ext.data.Model). I made the following changes:

    removeRecord: function(record) {

        var me = this;
        var id = record.internalId || record[me.pkField] || record.data[me.pkField];

a few bugs:

  • 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;
    },

Table never created

The CREATE TABLE SQL that was getting executed was incorrect, because it included the primary key twice. I updated constructFields to have the following:

...
Ext.each(fields, function(f) {
            var name = f.name;
            if (name == me.pkField) { // added this
                return; // added this
            } // added this
            var type = f.type.type;
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.