On Wed, Dec 9, 2009 at 8:17 PM, Mario Briggs <mario.bri...@in.ibm.com> wrote:
> I was too harsh on the GenericKeyField. How about GenericKeyField
> (length=x). I think the reason i put length in there is obvious, but i
> can explain if need be.

Well, you may have to, because the reason that it doesn't need a
length is also obvious, and I've already explained it. To clarify:

The *only* reason that we are even talking about adding this field is
because DB2 can't index on the datatype that is the natural match for
a length-unlimited TextField.

That means that the DB2 backend needs to be able to differentiate
between text fields that are actually storing length-unlimited text,
and text fields that are being used as a generic key store.

Now, a field is either a generic key field, or it isn't. If it is, it
needs to be able to store as generic a key as the backend will allow.
Ideally, that would be an length-unlimited text field, and on SQLite,
MySQL, Postgres and Oracle, it will be. However, this isn't possible
on DB2; but given that text fields aren't used as primary keys in
practice, a suitably long character limitation will suffice.

How long? Pick a number. It doesn't matter what number you pick - DB2
is the only database that will be affected, and whatever N you pick, I
will be able to produce a model with a CharField primary key with
length N+1 that will break it. You just need to pick an N such that
all practical use cases will be covered. Oracle's indexing imposes an
implicit limit of 4000 characters; that sounds to me like as good a
number as any.

As far as I can make out, there is absolutely no use case for
specifying a length in GenericKeyField. Feel free to let me know the
flaw in my reasoning.

Yours,
Russ Magee %-)

--

You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.


Reply via email to