For what it's worth I think this is *much* harder than it appears on the
surface. Whilst setting another field as the PK is easy, setting another
base type as an "auto" field is surprisingly tricky - lots of AutoField
assumes integers.

However, I do think it has some merits. An obvious benefit to the
consistency is when you are using another framework with Django which makes
certain assumptions about the way you identify objects. Some front end
frameworks prefer guids to integers, as would some security protocols.

M

On 1 Sep 2016 5:49 p.m., "Emett Speer" <speer.em...@gmail.com> wrote:

> I agree with you in recommending against using `.filter(pk=1)` in testing.
>
> What do you think of the idea though. Do you think it would be worth
> looking into adding a flag for new projects or not worth the time/effort to
> add it.
>
> On Wednesday, August 31, 2016 at 10:11:55 PM UTC-7, Shai Berger wrote:
>>
>> On Thursday 01 September 2016 02:51:54 Josh Smeaton wrote:
>> > A major issue with this would be the many apps out in the wild (and
>> their
>> > tests!) that assume the pk is an integer, and do queries like
>> > .filter(pk=1).
>>
>> FWIW, this is a bad practice which we should recommend against. In
>> databases
>> which rely on sequences, after you've run some tests, the pk of the first
>> record in a table is not necessarily 1 (because records in the table are
>> removed when test transactions are rolled back, but sequence values are
>> not
>> re-used). Similar issues can arise in parallel execution of tests.
>>
>> [This is a bit off-topic for the pk-type setting idea, I know]
>>
>> Shai.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/4422aad9-a9aa-4076-b24a-
> 659c0594e4f9%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/4422aad9-a9aa-4076-b24a-659c0594e4f9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMwjO1F9_ftSGLnaGQPp73CLrn6L167qVZMeTOOuasiTEWZSkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to