Obscure Primary Key Gotcha
Obscure Primary Key Gotcha
- Subject: Obscure Primary Key Gotcha
- From: Paul Lynch <email@hidden>
- Date: Thu, 19 Oct 2006 20:09:35 +0100
I just came across this, and thought the list might be interested:
I was just working with a legacy database which has a table with a
single column, which is of course designated as the primary key. It
happens to be a float, represented as a BigDecimal. The (somewhat
dubious) logic behind this design isn't important.
If I add a record to the table (EOGenericRecord), with the key field
set to a number greater than 1.0, everything is fine. However, if I
add a record with a value between 0 and 1.0 (which is the vast
majority of the records required), WO silently replaces the value
with the next available value from EO_PK_TABLE.
The reason behind this is that EO expects a primary key, when
supplied by the user, to be non-null and non-zero. It is obviously
(and mistakenly) assuming that values less than 1 are equal to zero -
probably because some programmer in the past thought that no one
would be dumb enough to use a float as a primary key :-).
Incidentally, the above is what happens using OpenBase; the MySQL
driver just generates an exception claiming it is unable to generate
a primary key.
Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden