Which DB are you using BTW? Because if you're using something like MySQL; they have inbuilt autoincrement fields which would be much better to utilise than what we provide in the DAL.
Maybe we should have an 'autoincrement' field, like we have a 'datetime' field? Gracefully degrade to a lambda if there isn't native autoincrement support. On Tue, Jan 29, 2013 at 1:44 AM, szimszon <szims...@gmail.com> wrote: > Hi! > > I wonder if somebody could help me. > > The > > definet_table('sometable', > Field('otherid', compute=lambda r: r['id']) > ) > > > doesn't work for me. :( Sould it work? With other than r['id'] it's working. > > Version 2.4.1-alpha.2+timestamp.2013.01.27.10.24.17 > > > 2010. május 28., péntek 16:02:23 UTC+2 időpontban mdipierro a következőt > írta: >> >> yes >> >> On May 28, 3:44 am, Mathieu Clabaut <mathieu.clab...@gmail.com> wrote: >> > I guess that one may want some more constraints on the autoincrement >> > field. >> > For example, it shall begin at 100 for ecample. >> > It may be because for example, before the application exists some paper >> > records where made which were referenced by number < 100) >> > >> > For such a problem, I've set up with: >> > >> > Field('ref_number', compute=lambda r: r['id'] + 100) >> > >> > Which I hope would eliminate the race solution as it is calculate upon >> > insertion in the database... Is it the case ? >> > >> > -Mathieu >> > >> > On Thu, May 27, 2010 at 23:25, mdipierro <mdipie...@cs.depaul.edu> >> > wrote: >> > > What is wrong with the default id field that web2py creates for every >> > > table? >> > >> > > On May 27, 3:16 pm, matclab <mathieu.clab...@gmail.com> wrote: >> > > > Hello, >> > > > I'm finding this message in a thread from February... >> > >> > > > I thought that autoincremented field would guaranty unicity in the >> > > > table. >> > > > I'm afraid the provided solution would allow two record to have the >> > > > same autonumber field (think about an access from two users at the >> > > > same time). >> > > > I guess the autoincrement should be done on the DAL or database >> > > > side, >> > > > inside a transaction.... >> > >> > > > What do you think about it ? >> > >> > > > On 19 jan, 21:38, Thadeus Burgess <thade...@thadeusb.com> wrote: >> > >> > > > > max_id= db(db.table.autonumber>1).select(db.table.autonumber, # >> > > > > select all records, and only pull the autonumber column >> > > > > orderby=~db.table.autonumber, # >> > > > > descending sort on the autonumber, (highest first) >> > > > > limitby=(0,1) # limit the query >> > > > > and >> > > > > only select the first record >> > > > > ).first().autonumber # pull the first >> > > > > record >> > > > > from the web2py rows object, and get its autonumber member >> > >> > > > > db.table.autonumber.default = max_id + 1 # Set the table default >> > > > > as >> > > > > the last autonumber and incremented by one. >> > > > > db.table.autonumber.writable = False >> > >> > > > > form = crud.create(db.table) >> > >> > > > > -Thadeus >> > >> > > > > On Tue, Jan 19, 2010 at 4:32 AM, ceriox <cer...@gmail.com> wrote: >> > > > > > thanks for the reply but i'm not a good web2py programmer ... i >> > > > > > writing my first real app >> > > > > > you can write the code for my request? (i can't understand the >> > > > > > post >> > > of >> > > > > > your link) >> > >> > > > > > -- >> > > > > > You received this message because you are subscribed to the >> > > > > > Google >> > > Groups "web2py-users" group. >> > > > > > To post to this group, send email to web...@googlegroups.com. >> > > > > > To unsubscribe from this group, send email to >> > > web2py+un...@googlegroups.com<web2py%2bunsubscr...@googlegroups.com> >> > > . >> > > > > > For more options, visit this group athttp:// >> > > groups.google.com/group/web2py?hl=en. > > -- > > > --