Hi,

I am adding a new record to a SQLiteStore using the following sample code. My primary key is membId and I am providing it's value as shown below (a string). However, after the record is added, the membId field in the store record contains the RowID in the table, not the key I passed it!

My record definition:
PHP Code:
WholeMealCafe.memberRec Ext.data.Record.create([
    {
name'membId'type:'string'},
    {
name'membParentId'type:'string'},
    {
name'membCode'type:'string'},
    {
name'membFirstname'type:'string'},
    {
name'membLastname'type:'string'},
    {
name'membEmail'type:'string'},
    {
name'isFolder'type:'boolean'}
]); 
My add test functionality:
PHP Code:
var pk Ext.uniqueId(true);
var 
rec = new WholeMealCafe.memberRec({
    
membIdpk,
    
membParentIdparentId,
    
membCode'TEST',
    
membFirstname'',
    
membLastname'',
    
membEmail'',
    
isFolderfalse
}, pk)

rec.phantom true;

WholeMealCafe.MemberStore.add(rec); 
The problem seems to be the following block in the Ext.data.SQLiteProxy.createCallback() method:
PHP Code:
if (action === Ext.data.Api.actions.create) {
    
air.trace('create callback=' data[reader.meta.idProperty]) // I added this

    
data[reader.meta.idProperty] = result.insertId;

    
air.trace('create callback new=' data[reader.meta.idProperty]) // I added this

and a sample output looks like:
Code:
create callback=092413758KWX1

create callback new=12
where 12 is the rowID in the table after inserting.

Now, result.insertId is passed by the Ext.data.SQLiteDB.createCallback() method:
PHP Code:
= {
    
records_this.readResults(res),
    
insertIdres res.lastInsertRowID null,
    
affectedRowsres res.rowsAffected null,
    
errore.error
}; 
It makes sense to me that res.lastInsertRowID is passed back to the caller. However, I am wondering why it is then used to set the primary key field without first checking whether a value is already in the record?

As a test I changed the block to
PHP Code:
if (action === Ext.data.Api.actions.create) {
    if (
data[reader.meta.idProperty] == '') {
        
data[reader.meta.idProperty] = result.insertId;
    }

and my problem was solved. However, that works for my setup but may break other use cases.

So, is that a bug or am I doing something wrong?

Thanks,
Murray