Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excess fields in db #5

Open
JohanVandeplas opened this issue Mar 9, 2012 · 5 comments
Open

Excess fields in db #5

JohanVandeplas opened this issue Mar 9, 2012 · 5 comments

Comments

@JohanVandeplas
Copy link

In the method constructFields you fetch the fields from the model. But not only my model fields got added but these extra fields too:

    parentId TEXT,
    index INTEGER,
    depth INTEGER,
    expanded bool,
    expandable bool,
    checked auto,
    leaf bool,
    cls TEXT,
    iconCls TEXT,
    root boolean,
    isLast boolean,
    isFirst boolean,
    allowDrop boolean,
    allowDrag boolean,
    loaded boolean,
    loading boolean,
    href TEXT,
    hrefTarget TEXT,
    qtip TEXT,
    qtitle TEXT

This resulted in an error when trying to add a column called index...

I temporary solved this by explicitly setting the 'isTableField: true' parameter and removing the part where it could be undefined.

Line 158:

    if(f.config.isTableField || !Ext.isDefined(f.config.isTableField)){
        /* ... */
    }

I'm not 100% shure but this proxy doesn't support treedata (yet), am I right? I would like to add that support.

You have any idea how to get the hasMany or hasOne properties out?

I got an Event model the event model hasMany 'cost' and hasMany 'participant'

me.getModel().prototype returns the the model and I see cost and costStore, participant and participantStore but can't find an array containing the child objects (ex: ['cost', 'participant'] ).

@tomalex0
Copy link
Owner

Can i see your exact model ?

@JohanVandeplas
Copy link
Author

(function(){
    /* Database Configurations */
    var dbconnval = {
        dbName: "EventManager",
        dbDescription: "database for EventManager"
    };
    Ext.DbConnection = new Ext.Sqlite.Connection(dbconnval);

    /* Model definition */
    Ext.define('eventManager.model.Event', {
        extend: 'Ext.data.Model',

        idProperty : 'uniqueid',
        clientIdProperty : 'id',

        config: {
            fields: [
                { name: 'id',        type: 'string', isTableField: true, fieldOption: 'PRIMARY KEY'},
                { name: 'name',      type: 'string', isTableField: true},
                { name: 'startTime', type: 'date',   isTableField: true, dateFormat: 'c'},
                { name: 'endTime',   type: 'date',   isTableField: true, dateFormat: 'c'},
                { name: 'createdBy', type: 'string', isTableField: true},
                { name: 'modId',     type: 'int',    isTableField: true},
                { name: 'eventType', type: 'string', isTableField: true},
                { name: 'location',  type: 'string', isTableField: true},
                { name: 'product',   type: 'string', isTableField: true},
                { name: 'objective', type: 'string', isTableField: true},
                { name: 'questionChecked',  type: 'boolean', isTableField: true},
                { name: 'question2Checked', type: 'boolean', isTableField: true}
            ],
            hasMany: [
                { model: 'eventManager.model.Cost', name: 'costs'},
                { model: 'eventManager.model.Participant', name: 'participants'}
            ]
        }
    });
})();

@tomalex0
Copy link
Owner

By default all fields in model will be created in table, if you want to avoid any specific fields from table mention like this

isTableField:false

@JohanVandeplas
Copy link
Author

my bad: files get decorated with extra params when using treedata:

Edit:
https://gist.github.com/2017112

I know the isTableField is supposed to leave out certain fields when set to false. I wanted to use your code and add support for storing treeData. What I didn't knew was when I add 'hasMany' the ST2.0 framework automatically adds those 20extra fields.Those fields didn't have a isTableField set to false so they automatically got added.

So it is not an issue, you can close the issue :)

I'll keep you posted on my progress! BTW: Nice work!

@tomalex0
Copy link
Owner

I think you can use https://gist.github.com/ to share code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants