Opened 17 years ago

Closed 17 years ago

Last modified 5 years ago

#5086 closed (fixed)

testing on postgres_psycopg2 tries to truncate tsearch2 tables

Reported by: shaunc <shaun@…> Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: shaun@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 (1)

owned-tables-only.patch (1.3 KB ) - added by shaunc <shaun@…> 17 years ago.
patch of ...introspection.get_table_list, returning by default only tables owned by current user

Download all attachments as: .zip

Change History (5)

by shaunc <shaun@…>, 17 years ago

Attachment: owned-tables-only.patch added

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

comment:1 by Yuri Baburov <burchik@…>, 17 years ago

Summary: testing on postgres_psychopg2 tries to truncate tsearch2 tablestesting on postgres_psycopg2 tries to truncate tsearch2 tables

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

comment:2 by Adrian Holovaty, 17 years ago

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.

comment:3 by Adrian Holovaty, 17 years ago

Resolution: fixed
Status: newclosed

(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@…

comment:4 by GitHub <noreply@…>, 5 years ago

Easy pickings: unset
UI/UX: unset

In f997b5e6:

Refs #5086 -- Removed unused only_django argument from sql_flush().

Unused (always True) since its introduction in 132605d889db8767a40243259066b8450428714c.

Note: See TracTickets for help on using tickets.
Back to Top