I had the same problem, and don't have a good answer to why this occurs.
Could be something specifically a bug with Postgresql? The problem don't occur which sqlite.
Besides, I always think the most annoying missing feature in web2py's DAL (and others orm's) is inability of use or adapt existent databases, without the boring redeclaring every field.
In a really "enterprise" environment, most of databases already exists, so most of development is around it.
I think in create a kind of wizard application to facilitate this task.
It would use the following logic:
1.Define a connection
2. List all tables of database.
3. choose the databases to work
4. list all fields of choosen tables
5. auto-detect field relationships
6. manually define field relationships
7. check for necessary requirements for DAL and suggest solutions; the user choose the most appropriate solution and apply.
(for me, solutions are only: create or rename the necessary field, especially id, would be could if DAL could accept declare a existent autoincrement field as id, while this real name is not. A possible solution is Postgresql is create a view redeclaring the name the field = my_id as id. )
8. DAL, as almost every orm, have a limited subset of fieldtypes, for compatibility for all databases. If a existent database have a non-standard DAL's fieldtype, is necessary define a solution how treat the data. So is necessary define a kind of conversion routine reading and writing for every non-standart fieldtype. The wizard would sugest some options or let the user define their own code.
9. Finally, everything checked, generates the db model, including migrate=False.
Something missing or any ideas?
--
Atenciosamente
--
=========================
Alexandre Andrade
Hipercenter.com