Re: [Django] #22492: provide a way to prevent database queries on model objects

2024-04-06 Thread Django
#22492: provide a way to prevent database queries on model objects
-+-
 Reporter:  Chris Jerdonek   |Owner:  Raúl
 |  Cumplido
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  model,queryset,defer,only  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Simon Charette):

 * cc: Adam Johnson (added)

Comment:

 FWIW this is being worked on through #28586 which adds modes to configure
 how deferred fields should behave when accessed.
-- 
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/0107018eb51c925f-14e9b237-09e5-4684-aecb-02a43e796cd2-00%40eu-central-1.amazonses.com.


Re: [Django] #22492: provide a way to prevent database queries on model objects

2023-02-02 Thread Django
#22492: provide a way to prevent database queries on model objects
-+-
 Reporter:  Chris Jerdonek   |Owner:  Raúl
 |  Cumplido
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  model,queryset,defer,only  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Andrea F):

 I want a feature that is similar to what was original described but for a
 different use case: I have a Celery task that needs a model object in the
 state it was when the task was enqueued, ''not'' in a state reflecting the
 corresponding database row(s) when the task is processed. I pass the
 object to the Celery task by serializing the entity (using
 `django.serializers`) and saving exactly the information I want to make
 available to the task.

 This object model has complex inner workings and multiple foreign keys. I
 want to be able to use the object model functionality and custom logic we
 have implemented in the model class, but I do _not_ want it reading (or
 writing) anything from the database after deserialization in the Celery
 task.

 For this I want something less "smart" than a feature that knows about
 `only` and `defer` and `QuerySet` objects. For this I want to be able to
 set a flag on an object that would disable any further database
 interactions originating from that object.

-- 
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/01070186145d3438-b3970cc6-dc39-43dc-b83d-f57113c05572-00%40eu-central-1.amazonses.com.


Re: [Django] #22492: provide a way to prevent database queries on model objects

2021-10-26 Thread Django
#22492: provide a way to prevent database queries on model objects
-+-
 Reporter:  Chris Jerdonek   |Owner:  Raúl
 |  Cumplido
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  model,queryset,defer,only  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Hannes Ljungberg):

 * cc: Hannes Ljungberg (added)


-- 
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/067.1f099ff458de9f385e8889ebe5cbd618%40djangoproject.com.


Re: [Django] #22492: provide a way to prevent database queries on model objects

2020-08-14 Thread Django
#22492: provide a way to prevent database queries on model objects
-+-
 Reporter:  Chris Jerdonek   |Owner:  Raúl
 |  Cumplido
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  model,queryset,defer,only  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Cesar Canassa):

 * cc: Cesar Canassa (added)


-- 
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/067.a8998c6ed4be9efd5413f4eb878bda0f%40djangoproject.com.


Re: [Django] #22492: provide a way to prevent database queries on model objects

2019-10-16 Thread Django
#22492: provide a way to prevent database queries on model objects
-+-
 Reporter:  Chris Jerdonek   |Owner:  Raúl
 |  Cumplido
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  model,queryset,defer,only  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Carlton Gibson):

 #26481 was also a duplicate.

-- 
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/067.ff330db30e0294e6490b390ff5d09ca9%40djangoproject.com.


Re: [Django] #22492: provide a way to prevent database queries on model objects

2019-10-14 Thread Django
#22492: provide a way to prevent database queries on model objects
-+-
 Reporter:  Chris Jerdonek   |Owner:  Raúl
 |  Cumplido
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  model,queryset,defer,only  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Simon Charette):

 #30874 was a duplicate.

-- 
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/067.8f275e70472b3ddcaee8f2180588c87d%40djangoproject.com.


Re: [Django] #22492: provide a way to prevent database queries on model objects

2019-10-14 Thread Django
#22492: provide a way to prevent database queries on model objects
-+-
 Reporter:  Chris Jerdonek   |Owner:  Raúl
 |  Cumplido
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  model,queryset,defer,only  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Simon Charette):

 FWIW a third party application implements such queryset sealing
 capabilities.

 {{{#!python
 In [1]: from polls.models import Choice

 In [2]: p = Choice.objects.defer('body_yes').seal()

 In [3]: choice = p[0]

 In [4]: choice.body_yes

 Traceback (most recent call last):
   File "<>", line xxx, in 

 UnsealedAttributeAccess:: Attempt to fetch deferred field "body_yes" on
 sealed .
 }}}

-- 
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/067.f46b77c40dc8bcba1cf70015c6e0188a%40djangoproject.com.


Re: [Django] #22492: provide a way to prevent database queries on model objects

2015-01-24 Thread Django
#22492: provide a way to prevent database queries on model objects
-+-
 Reporter:  cjerdonek|Owner:  raulcd
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  model,queryset,defer,only  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by raulcd):

 Is something like this a possible solution. I am thinking on the API, or
 do we prefer a solution where we have a context manager?


 {{{
 In [1]: from polls.models import Choice

 In [2]: p = Choice.objects.defer('body_yes', 'id')

 In [3]: choice = p[0]

 In [4]: choice.no_query_deferred = True

 In [5]: choice.body_yes

 Traceback (most recent call last):
   File "<>", line xxx, in 
 QueryException: no_query flag is set to True and a query has been
 attempted.

 In [6]: choice.no_query_deferred = False

 In [7]: choice.body_yes
 Out[7]: u'yes'

 }}}

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.5714efa5af5d9decd7c43dd5e89ae23f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #22492: provide a way to prevent database queries on model objects

2015-01-24 Thread Django
#22492: provide a way to prevent database queries on model objects
-+-
 Reporter:  cjerdonek|Owner:  raulcd
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  model,queryset,defer,only  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by raulcd):

 * cc: raulcumplido@… (added)
 * status:  new => assigned
 * owner:  nobody => raulcd


--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.d27e277583d713a028e6584c951f1551%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #22492: provide a way to prevent database queries on model objects

2014-04-28 Thread Django
#22492: provide a way to prevent database queries on model objects
-+-
 Reporter:  cjerdonek|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:   |  Needs documentation:  0
  model,queryset,defer,only  |  Patch needs improvement:  0
Has patch:  0|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-
Changes (by timo):

 * version:  1.6 => master
 * stage:  Unreviewed => Accepted


Comment:

 Seems like an interesting idea to at least explore.

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.bc351326caf50269261f0ab36774af89%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #22492: provide a way to prevent database queries on model objects

2014-04-22 Thread Django
#22492: provide a way to prevent database queries on model objects
-+-
 Reporter:  cjerdonek|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  1.6
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:
 Keywords:   |  Unreviewed
  model,queryset,defer,only  |  Needs documentation:  0
Has patch:  0|  Patch needs improvement:  0
  Needs tests:  0|UI/UX:  0
Easy pickings:  0|
-+-
Changes (by cjerdonek):

 * cc: chris.jerdonek@… (added)
 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.b95481493970d0e301165853060bb88a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #22492: provide a way to prevent database queries on model objects

2014-04-22 Thread Django
#22492: provide a way to prevent database queries on model objects
-+-
 Reporter:  cjerdonek|  Owner:  nobody
 Type:  New feature  | Status:  new
Component:  Database layer   |Version:  1.6
  (models, ORM)  |   Keywords:
 Severity:  Normal   |  model,queryset,defer,only
 Triage Stage:  Unreviewed   |  Has patch:  0
Easy pickings:  0|  UI/UX:  0
-+-
 This is a feature request to provide a way to prevent database queries
 from happening in a block of code, especially on model objects (e.g. using
 a context manager, or an internal flag on model objects).

 The motivation is for use with the QuerySet method
 [https://docs.djangoproject.com/en/dev/ref/models/querysets/#only
 `only()`], for example.  (The `only()` method is used to prevent
 unnecessary fields from being loaded from a database when querying.)
 Consider the case of using `only()` to retrieve a list of many model
 objects, and then subsequently displaying them.  If one executes some
 Django code after obtaining this list (e.g. by looping through the list of
 objects), it would be bad if this later code accidentally accessed some
 other field on each object. This could trigger the unintentional execution
 of many individual database queries (e.g. on a production database), with
 potentially bad consequences.  I don't currently know an easy way to
 prevent this.

 It would be good to have such a way.  For example, Django could provide
 some sort of `noQuery()` context manager which would raise an exception if
 the database were queried inside it.  Code after the `only()` line could
 be included in such a context manager.  This could prevent accidentally
 hammering a database.

 Alternatively, the QuerySet API could expose a way to return objects with
 some sort of `no_query` flag set.  If attribute access on such a model
 object required a database query, objects with such a flag set could
 instead raise an exception.  This would also suffice to prevent accidental
 queries.

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.46d20b5edfa1a9c947292c4e07e9ed83%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.