#27406: Signals pre_delete and post_delete break logical relationship of models 
and
behave in diffrently with different backends
-------------------------------------+-------------------------------------
     Reporter:  Seti                 |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  new
    Component:  Database layer       |                  Version:  1.10
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  Databases            |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Seti):

 Replying to [comment:1 Tim Graham]:
 > Maybe #24228 ("Signals have unclear & inconsistent transaction
 handling") is related? It would be nice to update the ticket description
 with a high level description of the problem so that it's not required to
 view the link to understand the basics.

 I made description of the problem in REAMDE of repository. Did you at
 least looked to repository?

 The problem exists as with the setting ATOMIC_REQUESTS = True or
 ATOMIC_REQUESTS = False (on the PostgreSQL exactly).

 I will try describe the problem:

 Custom the app 'users' contains three models: User, Vote and Notification.

 User - my own implementation of a user model;

 Vote - keep votes of a user by date; Has CASCADE related with the model
 User by field user;

 Notification - keep notification about actions of a user by field 'user';
 Namely register, unregister and add, update, delete vote. A user may be
 null in the field 'user'.

 Database schema
 [[Image(http://www.tiikoni.com/tis/view/?id=b6ddef1)]]

 Task is next:
 Save all actions of a user in the model Notification.

 I am use for it signals pre_delete, post_delete, post_save and own signal
 for write new records in the the model Notification.

 The signal post_save worked, but pre_delete, post_delete signals on
 PostgreSQL and MySQL. But all worked on the SQLite.

 Problem:
 if user will be deleted, it the field 'user' in the model Notification
 must be set to null. After user was deleted notifications about it must
 not be deleted.
 But this does not happen on on PostgreSQL and MySQL (see traceback
 
https://bitbucket.org/setivolkylany/test/src/318d38381d86cdc1421fec500c03a5a7ffa16b42/README.md?at=default&fileviewer
 =file-view-default). If I made disabled the signals pre_delete,
 post_delete - all worked:  a user is deleted, but notifications for him
 still exists in the model Notification.

 If something is does not clean, see code:
 
[https://bitb]ucket.org/setivolkylany/test/src/318d38381d86cdc1421fec500c03a5a7ffa16b42/apps/users/models.py?at=default&fileviewer
 =file-view-default;]
 
[https://bitbucket.org/setivolkylany/test/src/318d38381d86cdc1421fec500c03a5a7ffa16b42/apps/users/signals.py?at=default&fileviewer
 =file-view-default;]

 or tell me

 Sorry for English grammar mistakes

--
Ticket URL: <https://code.djangoproject.com/ticket/27406#comment:2>
Django <https://code.djangoproject.com/>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/071.bf348a903f54a69e89d79f2a8879f448%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to