db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Eade <se...@backstagetech.com.au>
Subject Re: Yet Another Sequence Bug in Postgres
Date Thu, 22 Apr 2004 02:18:19 GMT
Shevek wrote:

>If you insert a row into a postgres table with an explicitly specified
>primary id, it also tries to call currval on a sequence which has never
>been used.
>
>BasePeer should check whether an auto_incrementing primary was explicitly
>specified before trying to get it from a sequence which hasn't been used.
>
>The business case for doing this is that it's the only way to create a
>hierarchical structure: Since postgres enforces referential integrity
>constraints on null foreign keys, one must insert a row with known primary
>and self-referential foreign key, i.e. use an explicit primary.
>
>	Criteria criteria = new Criteria();
>	criteria.add(FooPeer.ID, id);
>	criteria.add(FooPeer.PARENTID, id);
>	HClassClassPeer.doInsert(criteria);
>
>Removing the 'create sequence' code from the postgres velocity templates
>seems to fix the earlier 'Cannot insert into postgres' bug. But on the
>basis that it requires a fix in torque to work with 7.3, I still believe
>that that earlier bug is outstanding in torque 3.1.
>
>Torque seems to be unable to cope with self referential constraints in any 
>way at all. It didn't generate any bean code for them either.
>  
>
I suggest you add this and your other issue to the PostgreSQL FAQ so 
that others can be informed about them.

As to fixing them, it is a matter of which itch a developer wants to 
scratch.  Your patches would be most welcome.

Scott

-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message