Changes between Initial Version and Version 1 of OracleBranch


Ignore:
Timestamp:
Apr 19, 2007, 12:58:40 PM (18 years ago)
Author:
ian.g.kelly@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OracleBranch

    v1 v1  
     1= The boulder-oracle-sprint branch =
     2
     3This branch began November 4, 2006 at a [http://wiki.python.org/moin/BoulderSprint code sprint] in Boulder, Colorado, whence it takes its name.  It aims to implement full support for the [http://www.oracle.com/ Oracle RDBMS].
     4
     5== How to get the branch ==
     6
     7{{{
     8svn co http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint/
     9}}}
     10
     11See our [http://www.djangoproject.com/documentation/contributing/#branch-policy branch policy] for full information on how to use a branch.
     12
     13== Goals ==
     14
     15The main goals of this branch are:
     16
     17  * Improve the oracle backend to the point where it can be used interchangeably with the existing supported backends.
     18
     19== Status ==
     20
     21=== Tablespace options ===
     22
     23A common paradigm for optimizing performance in Oracle-based systems is the use of [http://en.wikipedia.org/wiki/Tablespace tablespaces] to organize disk layout.  The Oracle branch supports this use case by adding ''tablespace'' options to Meta and Field classes.  When using a backend that lacks support for tablespaces, these options are ignored.
     24
     25A tablespace can be specified for the table(s) generated by a model by supplying the "tablespace" option inside the model's Meta class.  Additionally, the "tablespace" option can be passed to a Field constructor to specify an alternate tablespace for the Field's column index.  If no index would be created for the column, the "tablespace" option is ignored.
     26
     27{{{
     28class TablespaceExample(models.Model):
     29    name = models.CharField(maxlength=30, db_index=True, tablespace="indexes")
     30    data = models.CharField(maxlength=255, db_index=True)
     31    edges = models.ManyToManyField(to="self", tablespace="indexes")
     32
     33    class Meta:
     34        tablespace = "tables"
     35}}}
     36
     37In this example, the tables generated by the !TablespaceExample model (''i.e.'', the model table and the many-to-many table) would be stored in the "tables" tablespace.  The index for the name field and the indexes on the many-to-many table would be stored in the "indexes" tablespace.  The "data" field would also generate an index, but no tablespace for it is specified, so it would be stored in the model tablespace "tables" by default.
     38
     39=== Naming issues ===
     40
     41Oracle imposes a name length limit of 30 characters.  To accommodate this, the django.db.backends.util.truncate_name function has been added to truncate names to backend.get_max_name_length().  To prevent name collisions, the final 4 characters of the truncated name are generated from an MD5 hash.
     42
     43=== Backend !QuerySet classes ===
     44
     45A new mechanism is supplied by which backends can supply their own !QuerySet subclasses that will be used in place of !QuerySet, and that core !QuerySet subclasses (such as !DateQuerySet) will subclass.  The oracle backend uses this to override the iterator and _get_sql_clause methods in order to construct proper SQL for Oracle.  It is also used to provide a new resolve_columns method that the iterator method is expected to call in order to fetch corrected values.
     46
     47=== Empty strings ===
     48
     49Django generally prefers to use the empty string ('') rather than NULL, but Oracle treats the empty string as NULL.  To get around this, the oracle backend silently changes '' to ' ' when saving data. The inverse operation is automatically performed by !OracleQuerySet.resolve_columns when fetching from the database.
     50
     51=== Datetime conversion ===
     52
     53All communication of date and time-related fields with cx_Oracle requires the use of datetime.datetime objects rather than strings.  Code has been introduced to the Field classes to properly cast values for cx_Oracle, and the !OracleQuerySet.resolve_columns method is used to cast values from the database to the proper type for the Field.
     54
     55=== LOB manipulation ===
     56
     57The oracle backend stores !TextFields as NCLOB columns, for which cx_Oracle requires some extra manipulation to fetch.  This is automatically handled by !OracleQuerySet.resolve_columns.
     58
     59== To-do list ==
     60
     61(Updated April 19, 2007)
     62
     63  * The branch could use additional testing.
     64  * Rename the "tablespace" options to "db_tablespace" to match "db_table" and "db_index"?
     65  * Additional code refactoring for the !QuerySet.iterator and !QuerySet._get_sql_clause methods.
Back to Top