PS.
Of course you can also do:

db.define_table('sanzioni',
           SQLField('violazioni_codice'),
           SQLField('descrizione','text'),
           SQLField('sanzione',length=32),
           SQLField('note','text'))

db.sanzioni.violazioni_codice.requires=IS_IN_DB
(db,'violazioni.codice','%(codice)s')

and let web2py, not the db, enforce your relation.


On Nov 28, 10:05 am, mdipierro <[EMAIL PROTECTED]> wrote:
> I stand by my answer. Let me elaborate on it
>
> 1) do what Denes suggest:
>
> db.define_table('sanzioni',
>           SQLField('violazioni_id',db.violazioni),
>           SQLField('descrizione','text'),
>           SQLField('sanzione',length=32),
>           SQLField('note','text'))
>
> db.sanzioni.violazioni_id.requires=IS_IN_DB
> (db,'violazioni.id','violazioni.codice')
>
> and in all forms, codice will be shows instead of id.
>
> 2) in select:
>
> for row in db(db.sanzioni.violazioni_id==db.violazioni.id).select(): #
> do a join
>     print row.sanzioni.id, row.violazioni.codice
>
> I religiously believe it is the job of the database to create unique
> keys, not a job of the user.
>
> Massimo
>
> On Nov 28, 9:51 am, pmate <[EMAIL PROTECTED]> wrote:
>
> > Yes, but in this case field codice is unique too. The only difference
> > is that i want to choose its value, not the autoincrement of an id
> > field.
>
> > Paolo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to