#10716 closed (fixed)
Syntax error and bug in db/backends/oracle/creation.py
Reported by: | CanariX | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.0 |
Severity: | Keywords: | oracle | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Playing with the django tests on an Oracle DB, I've found 2 bugs in the db/backends/oracle/creation.py file :
- line 110, the line settings.DATABASE_NAME = TEST_DATABASE_NAME is missing. Without this line, Django could use the production DB instead of the test one (can be quite annoying).
This mod also impacts the mods on some other lines because of the "remember" dict.
- line 247, there's 2 typos : it should be "def _test_database_user(self, settings):" instead of "def _test_database_user(self, ettings):" and DATABASE_USER instead of DATABASE_NAME
I saw the problem in the 1.0.2 version, but the SVN has the same errors.
Julien
I attached a patch for the 1.0.2 version
Attachments (3)
Change History (11)
by , 16 years ago
Attachment: | creation.py.102.patch added |
---|
comment:1 by , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 16 years ago
comment:4 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
This "fix" actually prevents the test suite from running at all on Oracle here, and for Justin Bronn as well, so we're unable to know which tests are succeeding or failing any longer.
At this late date, this should be reverted.
by , 16 years ago
Attachment: | 10716-refix.diff added |
---|
comment:5 by , 16 years ago
Why are we assigning to settings.DATABASE_* here, that *should* not be occuring. I understand that settings.TEST_* is still handled globally, but that shouldn't be the case for DATABASE_*.
comment:6 by , 16 years ago
Added a patch that makes it possible to run tests on Oracle again.
First, the patch reverts the parts of the original fix that recorded TEST_DATABASE_NAME in settings.DATABASE_NAME. I really don't have much a clue when it comes to Oracle, but it appears that this change caused a problem because Oracle test database creation doesn't actually create a database, it creates a tablespace within the DATABASE_NAME. If you then overwrite DATABASE_NAME with the test database (tablespace for Oracle) name in settings, when running the tests an attempt is made to connect to the test tablespace as a database, but it's not a database, so the connect attempt for running the tests fails.
It's all a bit unclear to me but it appears things are set up so that by use of the test tablespace and a test user that uses that tablespace by default, all of the test table creation, etc. is isolated from the production DB. canarix, do you experience the test data actually interfering with the production DB? Or did the code just look wrong?
The fix to the ettings
instead of settings
typo also causes a problem as given the way the code is written test_
is being prepended to the database user name both when it is created and when it is destroyed. So given a database user of system
, the code will create user test_system
then attempt to destroy test_test_system
at the end. Recording the test user name as settings.TEST_USER_NAME avoids that problem so I opted for that instead of reverting what seems to be a clear typo in the original code. But someone with more of a clue on Oracle should probably take a look at this.
comment:7 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Karen's new patch looks sane enough to me, and does work. I made similar changes to the 1.0.X code and checked this in to both.
Patch for 1.0.2