From: David Jack Olrik Date: Sat, 3 Mar 2007 20:12:44 +0000 (+0000) Subject: Reverted accidental 'svk pull' from inside mirrored checkout. X-Git-Tag: v0.08010~150^2~92 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e9188247f020a63ab8b6280c9dcdcb0df5b5f0c1;p=dbsrgits%2FDBIx-Class.git Reverted accidental 'svk pull' from inside mirrored checkout. Note to self: Don't checkout anything from //mirror - Even if you have no need to edit it... --- diff --git a/Changes b/Changes index bcc8a45..f1671d7 100644 --- a/Changes +++ b/Changes @@ -1,12 +1,39 @@ Revision history for DBIx::Class -0.07005 2007-01-10 18:36:00 - - fixup changes file - - remove erroneous .orig files - oops - -0.07004 2007-01-09 21:52:00 +0.07999_02 2007-01-25 20:11:00 + - add support for binding BYTEA and similar parameters (w/Pg impl) + - add support to Ordered for multiple ordering columns + - mark DB.pm and compose_connection as deprecated + - switch tests to compose_namespace + - ResltClass::HashRefInflator added + - Changed row and rs objects to not have direct handle to a source, + instead a (schema,source_name) tuple of type ResultSourceHandle + +0.07999_01 2006-10-05 21:00:00 + - add connect_info option "disable_statement_caching" + - create insert_bulk using execute_array, populate uses it + - added DBIx::Class::Schema::load_namespaces, alternative to + load_classes + - added source_info method for source-level metadata (kinda like + column_info) + - Some of ::Storage::DBI's code/docs moved to ::Storage + - DBIx::Class::Schema::txn_do code moved to ::Storage + - Storage::DBI now uses exceptions instead of ->ping/->{Active} checks + - Storage exceptions are thrown via the schema class's throw_exception + - DBIx::Class::Schema::throw_exception's behavior can be modified via + ->exception_action + - columns_info_for is deprecated, and no longer runs automatically. + You can make it work like before via + __PACKAGE__->column_info_from_storage(1) for now + - Replaced DBIx::Class::AccessorGroup and Class::Data::Accessor with + Class::Accessor::Grouped. Only user noticible change is to + table_class on ResultSourceProxy::Table (i.e. table objects in + schemas) and, resultset_class and result_class in ResultSource. + These accessors no longer automatically require the classes when + set. + +0.07004 - fix find_related-based queries to correctly grep the unique key - - fix InflateColumn to inflate/deflate all refs but scalar refs 0.07003 2006-11-16 11:52:00 - fix for rt.cpan.org #22740 (use $^X instead of hardcoded "perl") diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index eaa6bc0..9184f2a 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -41,5 +41,5 @@ # Skip maint stuff ^maint/ -# Avoid copies to .orig -\.orig$ +# Dont use Module::Build anymore +# Build.PL diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 3ccd2af..f18ccfe 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -18,7 +18,7 @@ sub component_base_class { 'DBIx::Class' } # i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports # brain damage and presumably various other packaging systems too -$VERSION = '0.07005'; +$VERSION = '0.07999_02'; sub MODIFY_CODE_ATTRIBUTES { my ($class,$code,@attrs) = @_; diff --git a/lib/DBIx/Class/InflateColumn/DateTime.pm b/lib/DBIx/Class/InflateColumn/DateTime.pm index 6b012d8..27ceaeb 100644 --- a/lib/DBIx/Class/InflateColumn/DateTime.pm +++ b/lib/DBIx/Class/InflateColumn/DateTime.pm @@ -14,7 +14,7 @@ Load this component and then declare one or more columns to be of the datetime, timestamp or date datatype. package Event; - __PACKAGE__->load_components(qw/Core InflateColumn::DateTime/); + __PACKAGE__->load_components(qw/InflateColumn::DateTime/); __PACKAGE__->add_columns( starts_when => { data_type => 'datetime' } ); @@ -33,7 +33,7 @@ one your code should continue to work without modification (though note that this feature is new as of 0.07, so it may not be perfect yet - bug reports to the list very much welcome). -For more help with using components, see L. +For more help with components, see L. =cut diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index bd92f43..6c45d9b 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -107,15 +107,12 @@ to access the returned value: ); # Equivalent SQL: - # SELECT name name, LENGTH( name ) + # SELECT name name, LENGTH( name ) name_length # FROM artist -Note that the C< as > attribute has absolutely nothing to with the sql -syntax C< SELECT foo AS bar > (see the documentation in -L). If your alias exists as a -column in your base class (i.e. it was added with C), you -just access it as normal. Our C class has a C column, so -we just use the C accessor: +If your alias exists as a column in your base class (i.e. it was added +with C), you just access it as normal. Our C +class has a C column, so we just use the C accessor: my $artist = $rs->first(); my $name = $artist->name(); @@ -142,7 +139,7 @@ any of your aliases using either of these: select => [ { distinct => [ $source->columns ] } ], - as => [ $source->columns ] # remember 'as' is not the same as SQL AS :-) + as => [ $source->columns ] } ); @@ -179,10 +176,6 @@ L supports C as follows: # LEFT JOIN cd cds ON ( cds.artist = me.artistid ) # GROUP BY name -Please see L documentation if you -are in any way unsure about the use of the attributes above (C< join ->, C< select >, C< as > and C< group_by >). - =head3 Predefined searches You can write your own L class by inheriting from it @@ -422,7 +415,7 @@ ways, the obvious one is to use search: {}, { select => [ { sum => 'Cost' } ], - as => [ 'total_cost' ], # remember this 'as' is for DBIx::Class::ResultSet not SQL + as => [ 'total_cost' ], } ); my $tc = $rs->first->get_column('total_cost'); @@ -533,7 +526,7 @@ in the future. =head2 Many-to-many relationships -This is straightforward using L: +This is straightforward using L: package My::DB; # ... set up connection ... @@ -593,7 +586,7 @@ module. To make an object stringify itself as a single column, use something like this (replace C with the column/method of your choice): - use overload '""' => sub { shift->name}, fallback => 1; + use overload '""' => 'foo', fallback => 1; For more complex stringification, you can use an anonymous subroutine: @@ -1129,43 +1122,4 @@ Just use C instead, then check C: # do whatever else you wanted if it was a new row } -=head3 Wrapping/overloading a column accessor - -Problem: Say you have a table "Camera" and want to associate a description -with each camera. For most cameras, you'll be able to generate the description from -the other columns. However, in a few special cases you may want to associate a -custom description with a camera. - -Solution: - -In your database schema, define a description field in the "Camera" table that -can contain text and null values. - -In DBIC, we'll overload the column accessor to provide a sane default if no -custom description is defined. The accessor will either return or generate the -description, depending on whether the field is null or not. - -First, in your "Camera" schema class, define the description field as follows: - - __PACKAGE__->add_columns(description => { accessor => '_description' }); - -Next, we'll define the accessor-wrapper subroutine: - - sub description { - my $self = shift; - - # If there is an update to the column, we'll let the original accessor - # deal with it. - return $self->_description(@_) if @_; - - # Fetch the column value. - my $description = $self->_description; - - # If there's something in the description field, then just return that. - return $description if defined $description && length $descripton; - - # Otherwise, generate a description. - return $self->generate_description; - } - =cut diff --git a/lib/DBIx/Class/Manual/FAQ.pod b/lib/DBIx/Class/Manual/FAQ.pod index df0f773..928808c 100644 --- a/lib/DBIx/Class/Manual/FAQ.pod +++ b/lib/DBIx/Class/Manual/FAQ.pod @@ -255,36 +255,6 @@ Call C on a L, this returns a L, see it's documentation and the L for details. -=item .. fetch a formatted column? - -In your table schema class, create a "private" column accessor with: - - __PACKAGE__->add_columns(my_common => { accessor => '_hidden_my_column' }); - -Then, in the same class, implement a subroutine called "my_column" that -fetches the real value and does the formatting you want. - -See the Cookbook for more details. - -=item .. fetch a single (or topmost) row? - -Sometimes you many only want a single record back from a search. A quick -way to get that single row is to first run your search as usual: - - ->search->(undef, { order_by => "id DESC" }) - -Then call L and ask it only to return 1 row: - - ->slice(0,1) - -These two calls can be combined into a single statement: - - ->search->(undef, { order_by => "id DESC" })->slice(0,1) - -Why slice instead of L or L? -If supported by the database, slice will use LIMIT/OFFSET to hint to the database that we -really only need one row. This can result in a significant speed improvement. - =back =head2 Inserting and updating data @@ -326,35 +296,6 @@ scalar reference: ->update({ somecolumn => \'othercolumn' }) -=item .. store JSON/YAML in a column and have it deflate/inflate automatically? - -You can use L to accomplish YAML/JSON storage transparently. - -If you want to use JSON, then in your table schema class, do the following: - - use JSON; - - __PACKAGE__->add_columns(qw/ ... my_column ../) - __PACKAGE__->inflate_column('my_column', { - inflate => sub { jsonToObj(shift) }, - deflate => sub { objToJson(shift) }, - }); - -For YAML, in your table schema class, do the following: - - use YAML; - - __PACKAGE__->add_columns(qw/ ... my_column ../) - __PACKAGE__->inflate_column('my_column', { - inflate => sub { YAML::Load(shift) }, - deflate => sub { YAML::Dump(shift) }, - }); - -This technique is an easy way to store supplemental unstructured data in a table. Be -careful not to overuse this capability, however. If you find yourself depending more -and more on some data within the inflated column, then it may be time to factor that -data out. - =back =head2 Misc diff --git a/lib/DBIx/Class/Manual/Troubleshooting.pod b/lib/DBIx/Class/Manual/Troubleshooting.pod index eaa35fe..6087ae3 100644 --- a/lib/DBIx/Class/Manual/Troubleshooting.pod +++ b/lib/DBIx/Class/Manual/Troubleshooting.pod @@ -47,13 +47,5 @@ correctly. L version 1.50 and L 1.43 are known to work. -=head2 ... Can't locate object method "source_name" via package ... - -There's likely a syntax error in the table class referred to elsewhere -in this error message. In particular make sure that the package -declaration is correct, so for a schema C< MySchema > you need to -specify a fully qualified namespace: C< package MySchema::MyTable; > -for example. - =cut diff --git a/lib/DBIx/Class/Ordered.pm b/lib/DBIx/Class/Ordered.pm index 88e1110..d5a7a00 100644 --- a/lib/DBIx/Class/Ordered.pm +++ b/lib/DBIx/Class/Ordered.pm @@ -18,7 +18,27 @@ Create a table for your ordered data. position INTEGER NOT NULL ); -In your Schema or DB class add "Ordered" to the top +Optionally, add one or more columns to specify groupings, allowing you +to maintain independent ordered lists within one table: + + CREATE TABLE items ( + item_id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + position INTEGER NOT NULL, + group_id INTEGER NOT NULL + ); + +Or even + + CREATE TABLE items ( + item_id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + position INTEGER NOT NULL, + group_id INTEGER NOT NULL, + other_group_id INTEGER NOT NULL + ); + +In your Schema or DB class add Ordered to the top of the component list. __PACKAGE__->load_components(qw( Ordered ... )); @@ -29,7 +49,15 @@ each row. package My::Item; __PACKAGE__->position_column('position'); -That's it, now you can change the position of your objects. +If you are using one grouping column, specify it as follows: + + __PACKAGE__->grouping_column('group_id'); + +Or if you have multiple grouping columns: + + __PACKAGE__->grouping_column(['group_id', 'other_group_id']); + +Thats it, now you can change the position of your objects. #!/use/bin/perl use My::Item; @@ -75,7 +103,7 @@ move a record it always causes other records in the list to be updated. __PACKAGE__->position_column('position'); Sets and retrieves the name of the column that stores the -positional value of each record. Defaults to "position". +positional value of each record. Default to "position". =cut @@ -85,7 +113,7 @@ __PACKAGE__->mk_classdata( 'position_column' => 'position' ); __PACKAGE__->grouping_column('group_id'); -This method specifies a column to limit all queries in +This method specified a column to limit all queries in this module by. This effectively allows you to have multiple ordered lists within the same table. @@ -98,7 +126,7 @@ __PACKAGE__->mk_classdata( 'grouping_column' ); my $rs = $item->siblings(); my @siblings = $item->siblings(); -Returns either a resultset or an array of all other objects +Returns either a result set or an array of all other objects excluding the one you called it on. =cut @@ -122,7 +150,7 @@ sub siblings { my $sibling = $item->first_sibling(); Returns the first sibling object, or 0 if the first sibling -is this sibling. +is this sibliing. =cut @@ -142,7 +170,7 @@ sub first_sibling { my $sibling = $item->last_sibling(); -Returns the last sibling, or 0 if the last sibling is this +Return the last sibling, or 0 if the last sibling is this sibling. =cut @@ -163,8 +191,8 @@ sub last_sibling { my $sibling = $item->previous_sibling(); -Returns the sibling that resides one position back. Returns undef -if the current object is the first one. +Returns the sibling that resides one position back. Undef +is returned if the current object is the first one. =cut @@ -185,8 +213,8 @@ sub previous_sibling { my $sibling = $item->next_sibling(); -Returns the sibling that resides one position forward. Returns undef -if the current object is the last one. +Returns the sibling that resides one position foward. Undef +is returned if the current object is the last one. =cut @@ -208,9 +236,9 @@ sub next_sibling { $item->move_previous(); -Swaps position with the sibling in the position previous in -the list. Returns 1 on success, and 0 if the object is -already the first one. +Swaps position with the sibling on position previous in the list. +1 is returned on success, and 0 is returned if the objects is already +the first one. =cut @@ -224,9 +252,8 @@ sub move_previous { $item->move_next(); -Swaps position with the sibling in the next position in the -list. Returns 1 on success, and 0 if the object is already -the last in the list. +Swaps position with the sibling in the next position. 1 is returned on +success, and 0 is returned if the object is already the last in the list. =cut @@ -242,8 +269,8 @@ sub move_next { $item->move_first(); -Moves the object to the first position in the list. Returns 1 -on success, and 0 if the object is already the first. +Moves the object to the first position. 1 is returned on +success, and 0 is returned if the object is already the first. =cut @@ -256,8 +283,8 @@ sub move_first { $item->move_last(); -Moves the object to the last position in the list. Returns 1 -on success, and 0 if the object is already the last one. +Moves the object to the very last position. 1 is returned on +success, and 0 is returned if the object is already the last one. =cut @@ -271,9 +298,9 @@ sub move_last { $item->move_to( $position ); -Moves the object to the specified position. Returns 1 on -success, and 0 if the object is already at the specified -position. +Moves the object to the specified position. 1 is returned on +success, and 0 is returned if the object is already at the +specified position. =cut @@ -443,8 +470,8 @@ need to use them. =head2 _grouping_clause -This method returns a name=>value pair for limiting a search -by the collection column. If the collection column is not +This method returns one or more name=>value pairs for limiting a search +by the grouping column(s). If the grouping column is not defined then this will return an empty list. =cut @@ -512,7 +539,7 @@ ORDER BY on updates. If a position is not specified for an insert than a position will be chosen based on COUNT(*)+1. But, it first selects the -count, and then inserts the record. The space of time between select +count then inserts the record. The space of time between select and insert introduces a race condition. To fix this we need the ability to lock tables in DBIC. I've added an entry in the TODO about this. diff --git a/lib/DBIx/Class/Relationship.pm b/lib/DBIx/Class/Relationship.pm index b95867f..c987bb5 100644 --- a/lib/DBIx/Class/Relationship.pm +++ b/lib/DBIx/Class/Relationship.pm @@ -308,11 +308,6 @@ And, for the reverse relationship, from Role to Actor: My::DBIC::Schema::Role->many_to_many( actors => 'actor_roles', 'actor' ); -To add a role for your actor, and fill in the year of the role in the -actor_roles table: - - $actor->add_to_roles($role, { year => 1995 }); - Many_to_many is not strictly a relationship in its own right. Instead, it is a bridge between two resultsets which provide the same kind of convenience accessors as true relationships provide. Although the accessor will return a diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index a56285c..d51c4b9 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -1813,9 +1813,7 @@ Shortcut to include additional columns in the returned results - for example }); would return all CDs and include a 'name' column to the information -passed to object inflation. Note that the 'artist' is the name of the -column (or relationship) accessor, and 'name' is the name of the column -accessor in the related table. +passed to object inflation =head2 select @@ -1866,14 +1864,8 @@ Indicates additional column names for those added via L<+select>. =back -Indicates column names for object inflation. That is, c< as > -indicates the name that the column can be accessed as via the -C method (or via the object accessor, B). It has nothing to do with the SQL code C< SELECT foo AS bar ->. - -The C< as > attribute is used in conjunction with C contains one or more function or stored +Indicates column names for object inflation. This is used in conjunction with +C contains one or more function or stored procedure names: $rs = $schema->resultset('Employee')->search(undef, { diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 54374f1..e3c2b80 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -957,9 +957,7 @@ L, and set it here. $source->resultset_attributes({ order_by => [ 'id' ] }); -Specify here any attributes you wish to pass to your specialised -resultset. For a full list of these, please see -L. +Specify here any attributes you wish to pass to your specialised resultset. =cut diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index a26d34c..d66beb1 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -121,16 +121,12 @@ sub in_storage { =head2 update - $obj->update \%columns?; + $obj->update; Must be run on an object that is already in the database; issues an SQL UPDATE query to commit any changes to the object to the database if required. -Also takes an options hashref of C<< column_name => value> pairs >> to update -first. But be aware that this hashref might be edited in place, so dont rely on -it being the same after a call to C. - =cut sub update { diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 58a59db..4478d6f 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -1007,7 +1007,7 @@ sub ddl_filename { my ($self, $type, $dir, $version, $pversion) = @_; my $filename = ref($self); - $filename =~ s/::/-/g; + $filename =~ s/::/-/; $filename = File::Spec->catfile($dir, "$filename-$version-$type.sql"); $filename =~ s/$version/$pversion-$version/ if($pversion); diff --git a/t/76joins.t b/t/76joins.t index 405c726..538699f 100644 --- a/t/76joins.t +++ b/t/76joins.t @@ -412,4 +412,5 @@ TODO: { local $TODO = 'fixing collapse in -current'; is_deeply( $prefetch_result, $nonpre_result, 'Compare 2 level prefetch result to non-prefetch result' ); -} \ No newline at end of file +} +