PDA

View Full Version : [DUP] How to use sql proxy



xsense
1 Jun 2014, 10:31 PM
In document have this example


http://docs.sencha.com/extjs/5.0.0/apidocs/#!/api/Ext.data.proxy.Sql


Ext.require(["Ext.data.proxy.SQL"]);


Ext.define("User", { extend: "Ext.data.Model", config: { fields: [ "firstName", "lastName" ] } });


Ext.create("Ext.data.Store", {
model: "User",
storeId: "Users",
proxy: {
type: "sql"
}
});


Ext.getStore("Users").add({
firstName: "Polly",
lastName: "Hedra"
});


Ext.getStore("Users").sync();


but error

Uncaught TypeError: Cannot read property 'slice' of undefined

what's went wrong.

thank you.

mitchellsimoens
4 Jun 2014, 4:25 AM
I'm going to open this as a bug.

xsense
4 Jun 2014, 6:11 PM
thanks for reply.

nuhlir
13 Aug 2014, 7:17 AM
Tried it now with the new update of ExtJS and still not working! Anyone has any workaround?

ahz.100
15 Oct 2014, 1:35 AM
Any update on this? I am using ExtJS 5.0.0 and still see this error. SQL proxy is useless as long as this error is there. Anybody has a workaround?

ahz.100
30 Oct 2014, 5:11 AM
The line of code that produces this error is in the updateModel method of Ext.data.proxy.Sql class as shown below:


Ext.define('Ext.data.proxy.Sql', {
alias: 'proxy.sql',
extend: 'Ext.data.proxy.Client',
alternateClassName: 'Ext.data.proxy.SQL',


isSQLProxy: true,


config: {

reader: null,

writer: null,

table: null,

database: 'Sencha',


columns: '',


uniqueIdStrategy: false,


tableExists: false,


defaultDateFormat: 'Y-m-d H:i:s.u'
},


updateModel: function(model) {
if (model) {
var modelName = model.modelName,
defaultDateFormat = this.getDefaultDateFormat(),
table = modelName.slice(modelName.lastIndexOf('.') + 1);
..................................
.................................




Interestingly, the value of model is a constructor function instead of an object:


function constructor() {

return this.constructor.apply(this, arguments) || null;
}

ahz.100
24 Feb 2015, 8:50 AM
I was able to solve this issue using websql proxy from this repo:

https://github.com/tenrapid/extjs5-sqlite-proxy

Thanks to tenrapid =D>

dongryphon
3 Sep 2015, 10:58 AM
See also https://www.sencha.com/forum/showthread.php?301781-Sql-Proxy-for-ExtJS-6&p=1113677&viewfull=1#post1113677 for the status of the sql proxy in Ext JS 6.0.1