Re: [Django] #34378: Using in_bulk() with id_list and order_by()

2023-03-02 Thread Django
#34378: Using in_bulk() with id_list and order_by()
-+-
 Reporter:  Ekaterina|Owner:  Ekaterina
  Vakhrusheva|  Vakhrusheva
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  ib_bulk  | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"55bcbd8d172b689811fae17cde2f09218dd74e9c" 55bcbd8d]:
 {{{
 #!CommitTicketReference repository=""
 revision="55bcbd8d172b689811fae17cde2f09218dd74e9c"
 Fixed #34378 -- Made QuerySet.in_bulk() not clear odering when id_list is
 passed.

 This reverts 340eaded4e30cf25bcd4e9781d33a617fe9c0f84.
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186a656b8b6-7d07e693-d16c-4db3-add2-c29abdc142cd-00%40eu-central-1.amazonses.com.


Re: [Django] #34378: Using in_bulk() with id_list and order_by()

2023-03-02 Thread Django
#34378: Using in_bulk() with id_list and order_by()
-+-
 Reporter:  Ekaterina|Owner:  Ekaterina
  Vakhrusheva|  Vakhrusheva
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  ib_bulk  | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * stage:  Accepted => Ready for checkin


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186a5da3d84-ebc45ba5-857e-49e4-bf11-697da4900e8f-00%40eu-central-1.amazonses.com.


Re: [Django] #34378: Using in_bulk() with id_list and order_by()

2023-03-02 Thread Django
#34378: Using in_bulk() with id_list and order_by()
-+-
 Reporter:  Ekaterina|Owner:  Ekaterina
  Vakhrusheva|  Vakhrusheva
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  ib_bulk  | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Ekaterina Vakhrusheva):

 * has_patch:  0 => 1


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186a3dd166f-d935e766-1be7-45d4-9953-71fa8d403ba5-00%40eu-central-1.amazonses.com.


Re: [Django] #34378: Using in_bulk() with id_list and order_by()

2023-03-02 Thread Django
#34378: Using in_bulk() with id_list and order_by()
-+-
 Reporter:  Ekaterina|Owner:  Ekaterina
  Vakhrusheva|  Vakhrusheva
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  ib_bulk  | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Ekaterina Vakhrusheva):

 [https://github.com/django/django/pull/16613 PR]

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186a3dbe037-b778836d-c5e1-42f3-8631-6d9148386259-00%40eu-central-1.amazonses.com.


Re: [Django] #34378: Using in_bulk() with id_list and order_by()

2023-03-02 Thread Django
#34378: Using in_bulk() with id_list and order_by()
-+-
 Reporter:  Ekaterina|Owner:  Ekaterina
  Vakhrusheva|  Vakhrusheva
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  ib_bulk  | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak):

 [https://docs.djangoproject.com/en/dev/internals/contributing/writing-code
 /coding-style/ "Coding style"] can also be helpful.

 This is a bugfixes so docs changes are not necessary.
 We need a fix (it should be enough to remove `order_by()` from the
 `in_bulk()`
 
[https://github.com/django/django/blob/9953c804a9375956a542da94665662d306dff48d/django/db/models/query.py#L1107-L1113
 implementation]) and regression tests in `tests.lookup.tests.LookupTests`
 (please be sure that you covered both branches, with and without
 `batch_size`).

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186a18987fe-5c88e5dc-1f27-445f-9f73-0921d71c07dc-00%40eu-central-1.amazonses.com.


Re: [Django] #34378: Using in_bulk() with id_list and order_by()

2023-03-02 Thread Django
#34378: Using in_bulk() with id_list and order_by()
-+-
 Reporter:  Ekaterina|Owner:  Ekaterina
  Vakhrusheva|  Vakhrusheva
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  ib_bulk  | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Ekaterina Vakhrusheva):

 * owner:  nobody => Ekaterina Vakhrusheva
 * status:  new => assigned


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186a18170c7-d4453d72-d5f8-4b2a-8076-2aadda18a4c6-00%40eu-central-1.amazonses.com.


Re: [Django] #34378: Using in_bulk() with id_list and order_by()

2023-03-02 Thread Django
#34378: Using in_bulk() with id_list and order_by()
-+-
 Reporter:  Ekaterina|Owner:  nobody
  Vakhrusheva|
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  ib_bulk  | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Ekaterina Vakhrusheva):

 Yes, it would be great. But I’ve never done patches before. Is there
 anything I need to know about the patch creation process other than
 [https://docs.djangoproject.com/en/dev/internals/contributing/writing-code
 /submitting-patches/ this guide]

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186a18123e2-21c1b1db-e4b2-419b-add4-797d07ed5ee3-00%40eu-central-1.amazonses.com.


Re: [Django] #34378: Using in_bulk() with id_list and order_by()

2023-03-01 Thread Django
#34378: Using in_bulk() with id_list and order_by()
-+-
 Reporter:  Ekaterina|Owner:  nobody
  Vakhrusheva|
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  ib_bulk  | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak):

 Ekaterina, would you like to prepare a patch? (a regression test is
 required.)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186a13b918e-479c9931-dfa8-4bbe-a98f-8ca1ae309385-00%40eu-central-1.amazonses.com.


Re: [Django] #34378: Using in_bulk() with id_list and order_by()

2023-03-01 Thread Django
#34378: Using in_bulk() with id_list and order_by()
-+-
 Reporter:  Ekaterina|Owner:  nobody
  Vakhrusheva|
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  ib_bulk  | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * stage:  Unreviewed => Accepted


Comment:

 I think you misunderstood my reply: ''"it's **not** useless"''. I accepted
 the ticket.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186a135ea05-4f02835b-1596-4f4c-b9c7-7e3cc1de1dc0-00%40eu-central-1.amazonses.com.


Re: [Django] #34378: Using in_bulk() with id_list and order_by()

2023-03-01 Thread Django
#34378: Using in_bulk() with id_list and order_by()
-+-
 Reporter:  Ekaterina|Owner:  nobody
  Vakhrusheva|
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  ib_bulk  | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Ekaterina Vakhrusheva):

 Replying to [comment:1 Mariusz Felisiak]:
 > Ordering was removed in #15116, however we shouldn’t clear it anymore
 because dictionaries preserve the order, so it's not useless.

 i think, this is not useless, not only because dictionaries preserve the
 order, but also because the order of the elements of the queryset affects
 the value returned by .distinct()

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186a12bb8d2-cb41f55c-4570-490f-a35b-c7d034740ca2-00%40eu-central-1.amazonses.com.


Re: [Django] #34378: Using in_bulk() with id_list and order_by()

2023-03-01 Thread Django
#34378: Using in_bulk() with id_list and order_by()
-+-
 Reporter:  Ekaterina|Owner:  nobody
  Vakhrusheva|
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  ib_bulk  | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Ekaterina Vakhrusheva):

 * stage:  Accepted => Unreviewed


Old description:

> If you call in_bulk() together with the order_by(“field_1”,
> “field_2”).distinct(“field_1”) and specifying field_name=“field_1”, then
> when the result is received, the sorting order of the elements passed to
> order_by() is preserved. Code example:
>

> {{{
> locations = (
> UserLocation.objects.order_by("user_id", "-date_create")
> .distinct("user_id")
> .in_bulk(field_name="user_id")
> )
> print(locations)
> }}}
>
> **>>>{2693: }**
>
> However, if you specify an additional id_list argument in the in_bulk
> method, the sorting specified earlier in the request disappears, and as a
> result, another instance of the model is returned. Code example:
>

> {{{
> locations = (
> UserLocation.objects.order_by("user_id", "-date_create")
> .distinct("user_id")
> .in_bulk([2693], field_name="user_id")
> )
> print(locations)
> }}}
>
> **>>>{2693: }**
>
> A user with id 2693 has several locations that differ in the date_create.
> The most recent is with a time of **15:17**. When sorting queryset by
> “-date_create” I want to get the most recent record. Therefore, the
> sorting is reset when passing the id_list parameter.
>
> In my opinion, the sorting from queryset was removed before it was
> possible to pass different field_name to the in_bulk() method.
> Apparently, it was not taken into account that when sorting is reset, the
> result obtained when using DISTINCT changes.
>
> [https://forum.djangoproject.com/t/using-in-bulk/19192]

New description:

 If you call in_bulk() together with the order_by(“field_1”,
 “field_2”).distinct(“field_1”) and specifying field_name=“field_1”, then
 when the result is received, the sorting order of the elements passed to
 order_by() is preserved. Code example:


 {{{
 locations = (
 UserLocation.objects.order_by("user_id", "-date_create")
 .distinct("user_id")
 .in_bulk(field_name="user_id")
 )
 print(locations)
 }}}

 **>>>{2693: }**

 However, if you specify an additional id_list argument in the in_bulk
 method, the sorting specified earlier in the request disappears, and as a
 result, another instance of the model is returned. Code example:


 {{{
 locations = (
 UserLocation.objects.order_by("user_id", "-date_create")
 .distinct("user_id")
 .in_bulk([2693], field_name="user_id")
 )
 print(locations)
 }}}

 **>>>{2693: }**

 A user with id 2693 has several locations that differ in the date_create.
 The most recent is with a time of **15:17**. When sorting queryset by
 “-date_create” I want to get the most recent record. Therefore, the
 sorting is reset when passing the id_list parameter.

 In my opinion, the sorting from queryset was removed before it became
 possible to pass different field_name to the in_bulk() method. Apparently,
 it was not taken into account that when sorting is reset, the result
 obtained when using DISTINCT changes.

 [https://forum.djangoproject.com/t/using-in-bulk/19192]

--

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186a1285f9d-f7816852-71cf-45db-b3a4-1d2080d594c4-00%40eu-central-1.amazonses.com.


Re: [Django] #34378: Using in_bulk() with id_list and order_by()

2023-03-01 Thread Django
#34378: Using in_bulk() with id_list and order_by()
-+-
 Reporter:  Ekaterina|Owner:  nobody
  Vakhrusheva|
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  ib_bulk  | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * stage:  Unreviewed => Accepted


Comment:

 Ordering was removed in #15116, however we shouldn’t clear it anymore
 because dictionaries preserve the order, so it's not useless.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186a121bd58-3cccab22-f669-4db1-a945-a91ffe5be108-00%40eu-central-1.amazonses.com.