Django

Code

Ticket #5086 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

testing on postgres_psycopg2 tries to truncate tsearch2 tables

Reported by: shaunc <shaun@cuttshome.net> Assigned to: adrian
Milestone: Component: Database wrapper
Version: SVN Keywords:
Cc: shaun@cuttshome.net Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

I'm using tsearch2 together with django. Tsearch2 adds some special tables to the template database which are automatically created in each new database. So they don't get mixed up or deleted, I leave the user as "postgres" -- not owned by the user that django connects via.

This works fine... except that during testing the (django) test cases "truncate" all tables including the tsearch2 tables. These tables shouldn't be truncated, and (since django is not the owner to prevent just this sort of thing) the command fails.

I have solved in patch by having django.db.backends.postgresql_psychopg2.introspection.get_table_list return by default only tables that are owned by the current_user. I think this is a reasonable default in general, because other tables are likely to be not the concern of django anyway.

- Shaun Cutts

Attachments

owned-tables-only.patch (1.3 kB) - added by shaunc <shaun@cuttshome.net> on 08/04/07 17:28:38.
patch of ...introspection.get_table_list, returning by default only tables owned by current user

Change History

08/04/07 17:28:38 changed by shaunc <shaun@cuttshome.net>

  • attachment owned-tables-only.patch added.

patch of ...introspection.get_table_list, returning by default only tables owned by current user

08/05/07 23:11:55 changed by Yuri Baburov <burchik@gmail.com>

  • needs_better_patch changed.
  • summary changed from testing on postgres_psychopg2 tries to truncate tsearch2 tables to testing on postgres_psycopg2 tries to truncate tsearch2 tables.
  • needs_tests changed.
  • needs_docs changed.

Thanks! And what if my tsearch2 tables are owned by the same user like anything else?

08/25/07 14:03:58 changed by adrian

I agree that Django should not be truncating -- or even *touching* -- the tsearch2 tables. But I would even go as far as to say that Django should not touch *any* tables that it doesn't know about, regardless of which user account the table was created under.

I will change this so that Django doesn't touch tables that aren't defined in models.

08/25/07 14:32:31 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [6013]) Fixed #5086 -- The 'flush' and 'sqlflush' management commands no longer touch tables that Django is not aware of (tables that are not in INSTALLED_APPS and/or do not have associated models. Thanks for bringing this up, shaun@cuttshome.net


Add/Change #5086 (testing on postgres_psycopg2 tries to truncate tsearch2 tables)




Change Properties
Action