Opened 4 years ago

Closed 4 years ago

#32376 closed New feature (wontfix)

Allow destroy_test_db() not to fail if database doesn't exist

Reported by: Mateusz Mandera Owned by: nobody
Component: Database layer (models, ORM) Version: 3.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The situation
In our test setup we directly call connection.creation.destroy_test_db and the database that's meant to be dropped may or may not exist - the latter scenario is completely okay and shouldn't fail

The Problem
_destroy_test_db uses DROP DATABASE query, meaning an exception is thrown if the database doesn't exist

A possible solution
destroy_test_db could take an additional optional argument, which if True, would cause IF EXISTS to be used in the query.

Change History (1)

comment:1 by Mariusz Felisiak, 4 years ago

Component: Testing frameworkDatabase layer (models, ORM)
Resolution: wontfix
Status: newclosed
Summary: Allow destroy_test_db not to fail if database doesn't existAllow destroy_test_db() not to fail if database doesn't exist

In our test setup we directly call connection.creation.destroy_test_db and the database that's meant to be dropped may or may not exist - the latter scenario is completely okay and shouldn't fail

It's really unexpected that the database that you want to destroy doesn't exist, so an exception is desired. You can always handle it in your app, add a small wrapper, or
subclass the built-in database backends.

destroy_test_db could take an additional optional argument, which if True, would cause IF EXISTS to be used in the query.

This would require a separate logic on SQLite and Oracle, I don't think it's worth additional complexity. You can start a discussion on DevelopersMailingList if you don't agree.

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