DB Cache table creation (createcachetable) ignores the DB Router
|Reported by:||zvikico||Owned by:||Aymeric Augustin|
|Component:||Core (Cache system)||Version:||1.3-beta|
|Cc:||Aymeric Augustin||Triage Stage:||Accepted|
|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:10 Changed 5 years ago by
|Patch needs improvement:||set|
|Status:||closed → reopened|
|Triage Stage:||Ready for checkin → Accepted|
comment:14 Changed 5 years ago by
|Owner:||changed from nobody to Aymeric Augustin|
|Status:||reopened → new|