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 [email protected].
To post to this group, send email to [email protected].
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to