I am using django with mysql database.
{{{#!python
>>> len(ModelObject.objects.all())
89
>>> with transaction.atomic():
... ModelObject.objects.create(modelId="123")
... print(len(ModelObject.objects.all()))
...
<ModelObject: ModelObject object (16125)>
89
>>> len(ModelObject.objects.all())
90
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33064>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => worksforme
* component: Uncategorized => Database layer (models, ORM)
Comment:
Thanks for the report, however I cannot reproduce this issue on MySQL
(8.0.26, 5.6.50), SQLite, or PostgreSQL.
Please reopen the ticket if you can debug your issue and provide details
about why and where Django is at fault.
--
Ticket URL: <https://code.djangoproject.com/ticket/33064#comment:1>
Comment (by Dipen Sompura):
Replying to [comment:1 Mariusz Felisiak]:
> Thanks for the report, however I cannot reproduce this issue on MySQL
(8.0.26, 5.6.50), SQLite, or PostgreSQL.
>
> Please reopen the ticket if you can debug your issue and provide details
about why and where Django is at fault.
Thank you for looking into this. I am able to debug the issue. We are
using reader and writer db instance with following DB router:
{{{#!python
class DBRouter:
def db_for_read(self, model, **hints):
"""Return read replica."""
return 'replica1'
def db_for_write(self, model, **hints):
# Always return the default database
return 'default'
def allow_relation(self, obj1, obj2, **hints):
return True
def allow_migrate(self, db, app_label, model_name=None, **hints):
return True
}}}
Any suggestion, where we can use same writer instance for the atomic block
by keeping my DBRouter configuration as is?
--
Ticket URL: <https://code.djangoproject.com/ticket/33064#comment:2>