db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shevek <she...@anarres.org>
Subject Yet Another Sequence Bug in Postgres
Date Thu, 22 Apr 2004 01:38:52 GMT
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);

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.


Shevek                                    http://www.anarres.org/
I am the Borg.                         http://www.gothnicity.org/

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

View raw message