Thanks for your patch. I will include it. Currently in web2py you can only set unique multicol constraints at the web2py level (IS_NOT_IN_DB(subset,...)). This could be added but would make migrations a nightmare.
Massimo On Feb 12, 8:42 am, kralin <[email protected]> wrote: > I've being doing some testing > and actually setting > > primarykey=[] > > seems to work for creating tables without primary key > and read and write them. > > however appadmin interface crash because it expect a primarykey to > pass a query. > I fixed this by changing in appadmin.html: > > {{if request.function=='index':}} > <h1>{{=T("Available databases and tables")}}</h1> > {{if not databases:}}{{=T("No databases in this application")}} > {{pass}} > {{for db in sorted(databases):}} > {{for table in databases[db].tables:}} > {{qry='%s.%s.id>0'%(db,table)}} > {{tbl=databases[db][table]}} > {{if hasattr(tbl,'_primarykey'):}} > {{if tbl._primarykey:}} > {{firstkey=tbl[tbl._primarykey[0]]}} > {{if firstkey.type in ['string','text']:}} > {{qry='%s.%s.%s!=""'%(db,table,firstkey.name)}} > {{else:}} > {{qry='%s.%s.%s>0'%(db,table,firstkey.name)}} > {{pass}} > {{else:}} > {{qry=''}} > {{pass}} > {{pass}} > <h2>{{=A("%s.%s"% > (db,table),_href=URL(r=request,f='select',args=[db],vars=dict(query=qry)))}} > </h2> > [ {{=A(str(T('insert new'))+' > '+table,_href=URL(r=request,f='insert',args=[db,table]))}} ] > <br /><br /> > {{pass}} > {{pass}} > > one last thing. > Is there a way to set by the web2py DAL a multiple field constraint at > db level? > > let's say this is my db model: > > db.define_table('table_name', > Field('col_1','integer'), > Field('col_2','string'), > primarykey=[]) > > is it possible to set(using the DAL) at the db level a constraint so > that > the combination of col_1 and col_2 is unique? > if not are you planning to add constraint support to DAL? > > I know this can be done in the application, and I'm doing this way... > > On 10 Feb, 03:18, DenesL <[email protected]> wrote: > > > Don't wait for me, currently I have no plans to work on this. > > > On 9 feb, 10:47, kralin <[email protected]> wrote: > > > > Let me know if I can help. > > > > anyhow a good starting point would be making the table.insert() able > > > to return None > > > if no primary key or ID is defined. what do u think? is this > > > possible? > > > > On 8 Feb, 17:29, mdipierro <[email protected]> wrote: > > > > > You know I would take a patch > > -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to [email protected]. 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.

