Hi all.

I'm going mad on this problem.
Probably my lambda function for the represent products.brand is not correct 
but I don't know where.
Like that ny application works, but I cannot add some products rows, web2py 
says:"<class 'sqlite3.OperationalError'> foreign key mismatch"
db.define_table('brands',
                Field('id_01', 'id'),
                Field('name'),
                format='%(name)s')
db.define_table('products',
                Field('id_01', 'id'),
                Field('code'),
                Field('material_number'),
                Field('description'),
                #brand is an integer, the same as brands.id_01
                Field('brand', 'reference brands', requires = IS_IN_DB(db,db
.brands.id_01, '%(name)s'),
                      represent=lambda id, r: db.brands[id].name),
                Field('pdf_path'),
                Field('price_list', type='double'),
                Field('in_stock', type='integer'),
                format='%(code)s - %(price_list).2f')

Function argument list 

(self=<gluon.dal.SQLiteAdapter object>, table=<Table products (id_01,code,
material_number,description,brand,pdf_path,price_list,in_stock)>, fields=[(<
gluon.dal.Field object>, '6636356'), (<gluon.dal.Field object>, 'ghgh'), (<
gluon.dal.Field object>, 'ghhfh'), (<gluon.dal.Field object>, 782), (<gluon.
dal.Field object>, 45.0), (<gluon.dal.Field object>, 0), (<gluon.dal.Field 
object>, 'r35455')])

Code listing 

1306.
1307.
1308.
1309.
1310.
1311.

1312.
1313.
1314.
1315.

            self.execute(query)
        except Exception:
            e = sys.exc_info()[1]
            if hasattr(table,'_on_insert_error'):
                return table._on_insert_error(table,fields,e)
            raise e

        if hasattr(table,'_primarykey'):
            return dict([(k[0].name, k[1]) for k in fields \
                             if k[0].name in table._primarykey])
        id = self.lastrowid(table)



Someone can help me ?

Thanks.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to