DB Cache table creation (createcachetable) ignores the DB Router
|Reported by:||zvikico||Owned by:||aaugustin|
|Component:||Core (Cache system)||Version:||1.3-beta|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
When using database-based cache (using django.core.cache.backends.db.DatabaseCache cache backend), one uses the createcachetable command to create the table. This command completely ignores any database routers (in multiple databases situation) which are installed in the settings file. Instead, one can specify a target database with the --database option.
One could argue that this is not a bug, but rather a feature (undocumented one, none the less). However, the DatabaseCache class itself does use the installed router. This creates a confusion: if the router routes to a different database, one may install the table on the wrong database, but will not be able to access it.
I believe the best approach is to follow the syncdb convention: the cache table should not be created when the router returns false form the allow_syncdb method. The table will only be created when the matching DB is specified (or for the default if it is relevant).
Change History (21)
comment:1 Changed 5 years ago by russellm
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:10 Changed 5 years ago by jezdez
- Patch needs improvement set
- Resolution fixed deleted
- Status changed from closed to reopened
- Triage Stage changed from Ready for checkin to Accepted
- UI/UX unset
comment:14 Changed 5 years ago by aaugustin
- Owner changed from nobody to aaugustin
- Status changed from reopened to new