Code

Opened 22 months ago

Last modified 22 months ago

#18514 new Bug

Syncdb + Oracle + custom table name with quotes = Oracle 01741 error

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

Description

Using a custom table name with Oracle, and entering the full-qualified oracle schema + table name with quotes, is resulting in an Oracle 17141 error when running syncdb: "illegal zero-length identifier". The all-knowing Google indicates this is due to an empty string ("") being passed to Oracle.

Example Model:

class MyModel(models.Model):
	a_field = models.CharField(max_length=1000, blank=True, null=True)
	
	class Meta:
		db_table = u'"ORACLE_SCHEMA"."DESIRED_TABLE_NAME"'

Executing the syncdb management command to create that table results in the following:

$ ./manage.py syncdb
Creating table "ORACLE_SCHEMA"."DESIRED_TABLE_NAME"
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "[ intentionally obscured ]/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "[ intentionally obscured ]/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "[ intentionally obscured ]/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "[ intentionally obscured ]/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "[ intentionally obscured ]/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "[ intentionally obscured ]/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 99, in handle_noargs
    cursor.execute(statement)
  File "[ intentionally obscured ]/lib/python2.6/site-packages/django/db/backends/util.py", line 15, in execute
    return self.cursor.execute(sql, params)
  File "[ intentionally obscured ]/lib/python2.6/site-packages/django/db/backends/oracle/base.py", line 595, in execute
    return self.cursor.execute(query, self._param_generator(params))
django.db.utils.DatabaseError: ORA-01741: illegal zero-length identifier
ORA-06512: at line 8

The table is otherwise usable with the Django ORM once created - just errors on attempt to create via syncdb.

Attachments (0)

Change History (1)

comment:1 Changed 22 months ago by aaugustin

  • Keywords oracle added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.