I have found what causes it, in dal.py in PostgreSqlAdapter this method is supposed to return last inserted id:
def lastrowid(self,table = None): self.execute("select lastval()") return int(self.cursor.fetchone()[0]) This here http://stackoverflow.com/questions/17819001/postgres-not-returning-lastval-properly says this the wrong way to ask for ID and that it should be returned this way: insert into table ([columns]) values ([values]) returning id So it will return wrong ID everythime there is trigger that inserts something else somewhere else. I'm sending a bug report On Wednesday, August 6, 2014 12:43:38 PM UTC+2, Dragan Matic wrote: > > Version 2.9.5-stable+timestamp.2014.03.16.02.35.39 > Database drivers available: SQLite(sqlite3), MySQL(pymysql), > PostgreSQL(pg8000), IMAP(imaplib) > > Postgresql 9.3 on linux mint 17. > > trigger is BEFORE_INSERT > > On Wednesday, August 6, 2014 12:30:30 PM UTC+2, Niphlod wrote: >> >> it doesn't have to do with after_insert ..... it's something "broken" at >> the backend level..... what backend are you using dragan ? >> >> On Wednesday, August 6, 2014 12:24:15 PM UTC+2, Leonel Câmara wrote: >>> >>> Check _after_insert it's probably what you want. >>> >>> >>> http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#before-and-after-callbacks >>> >> -- 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/d/optout.