#22321 closed Bug (fixed)
Missing DB errors wrapping around _set_autocommit
| Reported by: | Alexander Koshelev | Owned by: | Aymeric Augustin | 
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev | 
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | yes | UI/UX: | no | 
Description
Implementation defined _set_autocommit function can raise DatabaseError that will not be wrapped and converted to unified exception class by caller in BaseDatabaseWrapper.set_autocommit.
Change History (9)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
| Summary: | Missing DB errors wraping around _set_autocommit → Missing DB errors wrapping around _set_autocommit | 
|---|
comment:3 by , 12 years ago
| Has patch: | set | 
|---|---|
| Owner: | changed from to | 
| Status: | new → assigned | 
| Triage Stage: | Unreviewed → Accepted | 
| Type: | Uncategorized → Bug | 
It turns out that I was working in this area today. See https://github.com/django/django/pull/2468.
comment:4 by , 12 years ago
Looks good but I don't understand why we cannot wrap exceptions in the one place – BaseDatabaseWrapper.set_autocommit?
comment:5 by , 12 years ago
For consistency. If you look at the rest of the class, database-level methods are prefixed with an underscore and that's where this handling belongs.
If a database adapter implementation autocommit in such a way that _set_autocommit couldn't raise an exception, it wouldn't need the exception wrapping (but that's a rather theoretical argument).
comment:7 by , 12 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | assigned → closed | 
Problem is located here – https://github.com/django/django/blob/master/django/db/backends/__init__.py#L277