Hi Leonel.
Yes it was like that before and the problem was the same.
requires = IS_IN_DB(db, db.brands.id, '%(name)s')
I've tried with id_01 because I want it to be my reference.
Il giorno mercoledì 25 dicembre 2013 01:13:30 UTC+1, Gael Princivalle ha
scritto:
>
> 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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.