Skip to content

Commit

Permalink
Added compatibility warning to MT::Object POD documentation about dat…
Browse files Browse the repository at this point in the history
…abase identifier name length.
  • Loading branch information
jayallen committed Jan 26, 2011
1 parent f7bd5ed commit 9f42f56
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions lib/MT/Object.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1796,9 +1796,6 @@ The name of the datasource for your class. The datasource is a name uniquely
identifying your class--it is used by the object drivers to construct table
names, file names, etc. So it should not be specific to any one driver.
Please note: the length of the datasource name should be conservative; some
drivers place limits on the length of table and column names.
=item * meta
Specify this property if you wish to support the storage of additional
Expand Down Expand Up @@ -2728,6 +2725,38 @@ object where I<foo> equals C<bar>, because it saves memory--only the
I<MT::Foo> objects that you will be deleting are kept in memory at the same
time.
=head2 Compatibility limitations on identifier name length
You should be conservative with the length of your datasource and column names
because some drivers place hard limits on the length of table identifiers
(e.g. Oracle's 30-character limit). The datasource is of specific concern
because it I<added to all other elements as a namespace identifier>.
For example, using a datasource like C<myclass_foobarbaz_map> with primary
key and indexed columns C<id>, C<foo_bar_id>, C<foo_baz_id> and C<bar_baz_id>
you might think you avoided the limit with the following identifiers:
Table: mt_myclass_foobarbaz_map (OK, 25 characters)
Columns: myclass_foobarbaz_map_id (OK, 25)
myclass_foobarbaz_map_foo_id (OK, 29)
myclass_foobarbaz_map_bar_id (OK, 29)
myclass_foobarbaz_map_baz_id (OK, 29)
However, you need to also remember that all driver's use a special name for
indexes and some create a sequence identifier to track autoincremented primary
keys. It's almost always the index names which exceed the length:
Sequence: mt_myclass_foobarbaz_map_id (OK, 28)
Indexes: mt_myclass_foobarbaz_map_foo_id (FAIL, 32)
mt_myclass_foobarbaz_map_bar_id (FAIL, 32)
mt_myclass_foobarbaz_map_baz_id (FAIL, 32)
The above would cause object initialization to fail completely making for a
very unhappy user of your code. By simply shortening the datasource value, you
can shorten every single identifier in the table.
=head1 SUBCLASSING
It is possible to declare a subclass of an existing MT::Object class,
Expand Down

0 comments on commit 9f42f56

Please sign in to comment.