[RDBO] $object->related_iterator
i've skimmed the docs again and don't see it, but is there an easy way to generate _iterator methods for one-to-many relationships? --- michael reece :: software engineer :: [EMAIL PROTECTED] - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Rose::DB::Object::Column::Serialize?
thanks again for this, svilen. i took what you posted, plus the followups from jsiracusa, and got something going. your code was very helpful. i made some slight adjustments, notably calling $class->freeze/thaw in the methodmaker, and implementing those as class methods there. that allowed me to do something like: package My::MethodMaker::Serialized::JSON; use base 'My::MethodMaker::Serialized'; use JSON; sub freeze { JSON->new->objToJson($_[1]) } sub thaw { JSON->new(skipinvalid => 1)->jsonToObj($_[1]) } 1; package My::MethodMaker::Serialized::YAML; use base 'My::MethodMaker::Serialized'; use YAML::Syck(); sub freeze { YAML::Syck::Dump($_[1]) } sub thaw { YAML::Syck::Load($_[1]) } 1; package My::MethodMaker::Serialized::Storable; use base 'My::MethodMaker::Serialized'; use Storable(); sub freeze { Storable::freeze($_[1]) } sub thaw { Storable::thaw($_[1]) } 1; add some little My::Column::Serialized::* wrappers to do the method_maker_class/type bits, plus this in My::MetaData __PACKAGE__->column_type_class(serialized_storable => 'Plex::RDBO::_serialized_storable_column'); __PACKAGE__->column_type_class(serialized_yaml => 'Plex::RDBO::_serialized_yaml_column'); __PACKAGE__->column_type_class(serialized_json => 'Plex::RDBO::_serialized_json_column'); and now i can __PACKAGE__->meta->setup( table => 'user', columns => [ ... payload => { type => 'serialized_yaml' }, ], ... and things are working great! regards, michael. On Jun 19, 2007, at 10:43 PM, Svilen Ivanov wrote: > Michael, > > Check this thread: > http://www.mail-archive.com/rose-db-object@lists.sourceforge.net/ > msg00260.html > > I hope that helps > > 2007/6/20, Michael Reece <[EMAIL PROTECTED]>: >> >> i am looking to freeze/thaw (or yaml, doesn't really matter..) >> unblessed data structures into a mysql column. >> >> has anyone already written a Column class that handles this >> transparently? >> >> --- >> michael reece :: software engineer :: [EMAIL PROTECTED] >> >> >> >> - >> >> This SF.net email is sponsored by DB2 Express >> Download DB2 Express C - the FREE version of DB2 express and take >> control of your XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/ >> ___ >> Rose-db-object mailing list >> Rose-db-object@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/rose-db-object >> > > -- > --- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > ___ > Rose-db-object mailing list > Rose-db-object@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rose-db-object --- michael reece :: software engineer :: [EMAIL PROTECTED] - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] Rose::DB::Object::Column::Serialize?
i am looking to freeze/thaw (or yaml, doesn't really matter..) unblessed data structures into a mysql column. has anyone already written a Column class that handles this transparently? --- michael reece :: software engineer :: [EMAIL PROTECTED] - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] augmenting ManyToMany default_auto_method_types
On Jun 11, 2007, at 9:22 AM, John Siracusa wrote: > On 6/11/07 12:14 PM, Michael Reece wrote: >> method_types => [ >> Rose::DB::Object::Metadata::Relationship::ManyToMany- >>> default_auto_method_types(), >> 'count' >> ], >> }, > > Try: > > add_methods => [ 'count' ], fantastic, thanks. i am in the process of porting some code from CDBI::Sweet to RDBO, and one thing that tripped me up trying to use an offset + rows, when rows s.b. 'limit' for RDBO.. i was getting an error like "Could not find MyDB::Message objects - at ..." after a little digging: in Rose::DB::Object::Manager, sub get_objects, ~ line 1608: if(defined $args{'offset'}) { Carp::croak "Offset argument is invalid without a limit argument" unless($args{'limit'} || $manual_limit); in Rose::DB::Object::MakeMethods::Generic, sub objects_by_map, ~ line 4314: if($@ || !$objs) { $self->error("Could not find $foreign_class objects - " . $map_manager->error); $self->meta->handle_error($self); return wantarray ? () : $objs; } however, the error is in $@ and not $map_manager->error, so the reason for the failure is not reported. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] augmenting ManyToMany default_auto_method_types
i've been writing my own count_related() methods and just realized that RDBO should be able to create these for me (but names them related_count).. is there a better way to get related_count() methods? attachments => { type => 'many to many', map_class=> 'MyDB::RelatedAttachment', map_from => 'asset', map_to => 'related', manager_args => { sort_by => 'related_asset.sort_order' }, method_types => [ Rose::DB::Object::Metadata::Relationship::ManyToMany- >default_auto_method_types(), 'count' ], }, is there a compelling reason to not have these _count methods created for all my *-to-many relationships? if not, how would i go about that cleanly? subclass Rose::DB::Object::Metadata::Relationship::ManyToMany, override default_auto_method_types, and then override relationship_type_classes in my Metadata base class, or is there a more sensible approach? thanks, michael. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Namespace for 3rd-party RDBO modules
On May 23, 2007, at 10:48 AM, John Siracusa wrote: > On 5/23/07 12:53 PM, Jonathan Vanasco wrote: >> On May 23, 2007, at 9:36 AM, John Siracusa wrote: >>> Does anyone have any good ideas for a namespace for module that >>> augment or >>> extend RDBO, but that are not part of the "official" RDBO >>> distribution? The >>> first thing that springs to my mind is: >>> >>> Rose::DBx::* >>> >> At first I really liked that, but then I read... >> >>> That'd be for both modules that are related to Rose::DB and >>> modules that are >>> related to Rose::DB::Object. >> >> Which would make it a bit awkward, I think, in the case of a >> Rose::DB derived file, and not an object file. > > How so? > >> My main worry is that Rose::DBx looks similar to Rose::DB > > Well, DBI did the DBIx thing, and Mason did the MasonX thing. I like > Rose::DBx:: more than RoseX::, but I could be persuaded. > >> Rose::Community >> Rose::Externals >> Rose::Contributed > > Those are all way too long :) > >> Rose::xDB might work too - it gets your original point across >> without looking too much like the real rose namespace. > > Yeah, that's not bad either. > > Other opinions? > > -John i think Rose::DBx is fine, and Rose::DBx::TotallyRad and Rose::DBx::Object::TotallyRad seem clear enough what's what to me. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] cascading Manager queries
in Collection.pm, i have sub count_assets { my $self = shift; return CollectionAsset::Manager->get_collection_assets_count( require_objects => ['asset'], query => [ collection_id => $self- >collection_id, @_ ], ); } sub count_assets_published { my $self = shift; return $self->count_assets('asset.pubstatus' => 'published', @_); } and later: my $count = $collection->count_assets_published( [ \'t2.pubdate >= NOW() - INTERVAL ? DAY' => $num_days ] # t2 ~> asset ); i can't refer to 'asset.pubdate' in this query param, because RDBOM insists i use a scalar-ref here, and wisely avoids doing substitutions when handed a scalar-ref, and mysql won't let me refer to the table by its real name once it has been aliased.. since the generated query aliases asset as t2, i have to use t2 here, though not elsewhere. needless to day, it's a little confusing, especially to future-maintenance-programmer. any advice? another thing i am struggling with a bit is allowing such helper methods to modify both the query and manager_args. in the above example, require_objects=>['asset'] isn't required in the basic case where it exists, but is there because methods like count_assets_published need to refer to the assets.. seems common enough, so maybe there is already a convenient way to merge manager args in this case? here is a bit of ugliness that hints at what i am after: sub count_assets { my $self = shift; my ($manager_args, $query_args) = _separate_manager_query_args(@_); return Plex::RDBO::CollectionAsset::Manager- >get_collection_assets_count( @$manager_args, query => [ collection_id => $self->collection_id, @ $query_args ], ); } sub count_assets_published { my $self = shift; my ($manager_args, $query_args) = _separate_manager_query_args(@_); return $self->count_assets( require_objects => ['asset'], @$manager_args, query => [ 'asset.pubstatus' => 'published', @ $query_args ] ); } sub _separate_manager_query_args { my @manager_args = @_; my @query_args; foreach my $i (0..$#manager_args) { if ($manager_args[$i] eq 'query') { @query_args = @{ (splice @manager_args, $i, 2)[1] }; last; } } return ([EMAIL PROTECTED], [EMAIL PROTECTED]); } any advice? ;) - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] sort_by computed/aggregate column
On May 15, 2007, at 11:32 AM, John Siracusa wrote: > On 5/15/07, Michael Reece <[EMAIL PROTECTED]> wrote: >>> but the generated query contains "ORDER BY t1.temp_asset_count DESC" >>> and i can't seem to get the "t1." not added to the ORDER BY clause. >>> >>> i know i can resort to get_objects_from_sql, but are there any other >>> suggestions? > > You're already beyond what the Manager is currently able to do by > using the undocumented group_by parameter... true, maybe i should just change it to SQL.. > >> this brings up another possibly useful feature, which would allow >> something like >> >>discard_columns => ['temp_asset_count'] >> >> to keep me from having to set up an accessor for temp_asset_count, >> which may never be used outside this sort_by clause. > > ...or just don't use MySQL 4 ;) On the sort_by thing, I'll probably > add the ability to pass a reference to a scalar which will be taken as > a literal. i tried passing a \'' to see if that was already implemented, but it griped it was not an array-ref. ;) - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] sort_by computed/aggregate column
On May 15, 2007, at 10:57 AM, Michael Reece wrote: > here > is what i tried: > > my $active = $self->get_groups( > distinct=> 1, > select => [ 't1.*', 'COUNT(DISTINCT t3.asset_id) as > temp_asset_count' ], > multi_many_ok => 1, > require_objects => ['collections.collection_assets'], > group_by=> 't1.group_id', > sort_by => 'temp_asset_count DESC', > ); > > but the generated query contains "ORDER BY t1.temp_asset_count DESC" > and i can't seem to get the "t1." not added to the ORDER BY clause. > > i know i can resort to get_objects_from_sql, but are there any other > suggestions? FYI, experimentation shows that i can get it to not prefix temp_asset_count with "t1." if i add some extra junk: sort_by => ['temp_asset_count DESC, "avoid prefixing temp_asset_count"'], but, ugh. this brings up another possibly useful feature, which would allow something like discard_columns => ['temp_asset_count'] to keep me from having to set up an accessor for temp_asset_count, which may never be used outside this sort_by clause. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] sort_by computed/aggregate column
i have a Group::Manager query like: my $active = $self->get_groups( distinct => 1, fetch_only => [ $self->object_class->meta->table ], ## silence warning from RDBOM about redundant data -- there is no ## redundant data anyway, because of 'fetch_only' multi_many_ok => 1, require_objects => ['collections.collection_assets'], group_by => 't1.group_id', sort_by => 'COUNT(DISTINCT collection_assets.asset_id) DESC', ); which produces a query that looks (roughly) like SELECT DISTINCT t1.* FROM agroup t1 JOIN (collection t2 JOIN collection_asset t3 ON (t2.collection_id = t3.collection_id)) ON (t1.group_id = t2.group_id) GROUP BY t1.group_id ORDER BY COUNT(DISTINCT t3.asset_id) DESC which works great for mysql 5.0.x, but mysql 4.1.x complains "Invalid use of group function" and wants me to do something like: SELECT DISTINCT t1.*, COUNT(DISTINCT t3.asset_id) as temp_asset_count FROM agroup t1 JOIN (collection t2 JOIN collection_asset t3 ON (t2.collection_id = t3.collection_id)) ON (t1.group_id = t2.group_id) GROUP BY t1.group_id ORDER BY temp_asset_count DESC but i can't seem to coerce this out of the get_objects() call. here is what i tried: my $active = $self->get_groups( distinct=> 1, select => [ 't1.*', 'COUNT(DISTINCT t3.asset_id) as temp_asset_count' ], multi_many_ok => 1, require_objects => ['collections.collection_assets'], group_by=> 't1.group_id', sort_by => 'temp_asset_count DESC', ); but the generated query contains "ORDER BY t1.temp_asset_count DESC" and i can't seem to get the "t1." not added to the ORDER BY clause. i know i can resort to get_objects_from_sql, but are there any other suggestions? --- michael reece :: software engineer :: [EMAIL PROTECTED] - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] re-using relationships with extra conditions
i forgot about that new feature! upgraded and tested, works great! On May 11, 2007, at 12:18 PM, John Siracusa wrote: > On 5/11/07, Michael Reece <[EMAIL PROTECTED]> wrote: >> 1. is there a way to pull that off with 'one to one' type >> relationship so i can drop the subroutine? > > Not unless you add an is_latest column or something to the table. > >> 2. or is there a way to tack on extra conditions (or custom ordering) >> to existing relationships, so i can keep the subroutine and drop the >> extra relationship? > > Check out the "find" method type: > > $latest = > $o->find_messages(sort_by => 'message.pubdate DESC', > limit => 1)->[0]; > > I guess you'd still want to wrap that in a nice method name, but at > least you don't have to create a new relationship. > > -John > > -- > --- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > ___________ > Rose-db-object mailing list > Rose-db-object@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rose-db-object --- michael reece :: software engineer :: [EMAIL PROTECTED] - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] re-using relationships with extra conditions
in CDBI (+Sweet), i would do something like this: Category->has_many( messages => [ 'CollectionMessage' => 'message' ], constraint => { 'message.atype' => 'discussion', 'message.pubstatus' => 'published' } ); sub latest_message { my $self = shift; my ($latest) = $self->messages({ order_by => 'pubdate DESC', rows => 1 }); return $latest; } the closest i have come up with in RDBO is: Category->meta->setup( # ... relationships => [ messages => { type => 'many to many', map_class => 'CollectionMessage', map_from => 'category', map_to => 'message', query_args => [ 'message.atype' => 'discussion', 'message.pubstatus' => 'published' ] }, latest_message_map => { type => 'many to many', map_class=> 'CollectionMessage', map_from => 'category', map_to => 'message', query_args => [ 'message.atype' => 'discussion', 'message.pubstatus' => 'published' ], manager_args => { sort_by => 'message.pubdate DESC', limit => 1 } } ] ); sub latest_message { my $self = shift; my $latest = $self->latest_message_map; return $latest && $latest->[0]; } i guess i have three questions. 1. is there a way to pull that off with 'one to one' type relationship so i can drop the subroutine? 2. or is there a way to tack on extra conditions (or custom ordering) to existing relationships, so i can keep the subroutine and drop the extra relationship? (what Class::DBI calls Limiting: http://search.cpan.org/~tmtm/Class- DBI-v3.0.16/lib/Class/DBI.pm#Limiting ) 3. am i missing some other RDBO magic that would make this easier? --- michael reece :: software engineer :: [EMAIL PROTECTED] - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] auto_prime_caches, or common custom Metadata
here's what i came up with: in package My::RDBO::_base, sub meta_class { 'My::RDBO::_meta' } and then, package My::RDBO::_meta; use base 'Rose::DB::Object::Metadata'; sub auto_prime_caches { 0 } 1; is this the expected way to do this sort of thing? On Mar 8, 2007, at 4:15 PM, Michael Reece wrote: > my $dbh isn't available at the time that mod_perl starts up. after a > couple hours of debugging, i figured out that i need to pass > > auto_prime_caches => 0, > > to __PACKAGE__->meta->setup(...) > > however, i have a lot of classes. is there a way to add this > behavior (or other similar metadata) to the base class (say, > My::RDBO)? > > --- > michael reece :: software engineer :: [EMAIL PROTECTED] > > > > -- > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php? > page=join.php&p=sourceforge&CID=DEVDEV > ___ > Rose-db-object mailing list > Rose-db-object@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rose-db-object --- michael reece :: software engineer :: [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] auto_prime_caches, or common custom Metadata
my $dbh isn't available at the time that mod_perl starts up. after a couple hours of debugging, i figured out that i need to pass auto_prime_caches => 0, to __PACKAGE__->meta->setup(...) however, i have a lot of classes. is there a way to add this behavior (or other similar metadata) to the base class (say, My::RDBO)? --- michael reece :: software engineer :: [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] unexpected fetchrow_array in scalar context
On Mar 7, 2007, at 12:17 PM, John Siracusa wrote: > On 3/7/07, Michael Reece <[EMAIL PROTECTED]> wrote: >> this was causing me problems (always getting counts of 1) because my >> DBI abstraction layer re-implements fetchrow_array, only ever >> returning a list. > > Well there's your problem :) indeed! >> "[...] For these reasons you should exercise some caution if you use >> fetchrow_array in a scalar context." >> >> [...] the last sentence does provide a warning, so perhaps you can be >> convinced to change RDBOM line 1500 to >> >> ($count) = $sth->fetchrow_array; > > In this case, I know that I'm only ever fetching one column > (COUNT(*)), so there's no ambiguity. I admit no wrongdoing; I'm > following the letter of the DBI spec! :) But I'll change it just for > you... ;) > > (in SVN) > -John thanks! - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] unexpected fetchrow_array in scalar context
this is not necessarily a bug in Rose::DB::Object::Manager, but it is questionable so i will raise the issue anyway. :) when calling get_foos_count, Rose::DB::Object::Manager->get_objects does: $count = $sth->fetchrow_array; this was causing me problems (always getting counts of 1) because my DBI abstraction layer re-implements fetchrow_array, only ever returning a list. indeed, it takes careful reading between the lines of the DBI docs to discern what exactly should happen when fetchrow_array is called in scalar context. from http://search.cpan.org/~timb/DBI-1.54/DBI.pm fetchrow_array @ary = $sth->fetchrow_array; An alternative to fetchrow_arrayref. Fetches the next row of data and returns it as a list containing the field values. Null fields are returned as undef values in the list. If there are no more rows or if an error occurs, then fetchrow_array returns an empty list. You should check $sth->err afterwards (or use the RaiseError attribute) to discover if the empty list returned was due to an error. If called in a scalar context for a statement handle that has more than one column, it is undefined whether the driver will return the value of the first column or the last. So don't do that. Also, in a scalar context, an undef is returned if there are no more rows or if an error occurred. That undef can't be distinguished from an undef returned because the first field value was NULL. For these reasons you should exercise some caution if you use fetchrow_array in a scalar context. the second to last sentence does imply that the first field is returned in scalar context (at least when there is only one column), so i have changed my re-implementation of fetchrow_array to do so, but the last sentence does provide a warning, so perhaps you can be convinced to change RDBOM line 1500 to ($count) = $sth->fetchrow_array; regards, michael. - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] inflating/deflating columns using mysql functions
this is what i am working with so far and works ok if all rows have the same encryption key: package RM::DB::Column::AESCrypt; use base 'Rose::DB::Object::Metadata::Column::Blob'; sub select_sql { my $self = shift; my $value = q{AES_DECRYPT(body, 'SECRET')}; return $value; } sub query_placeholder_sql { my $self = shift; my $value = q{AES_ENCRYPT(?, 'SECRET')}; return $value; } *insert_placeholder_sql = \&query_placeholder_sql; *update_placeholder_sql = \&query_placeholder_sql; 1; any suggestions on how to get 'SECRET' to come from the object, which does not appear to be passed to these subs? On Feb 28, 2007, at 2:13 PM, Michael Reece wrote: > this looks very promising! but what args are passed to select_sql, > etc? > > that is, from RM::DB::Column::AESCrypt sub select_sql, how can i > inspect the row/object to use its special crypt key? > > On Feb 28, 2007, at 1:47 PM, John Siracusa wrote: > >> On 2/28/07, Michael Reece <[EMAIL PROTECTED]> wrote: >>> is it possible to inflate/deflate columns using mysql functions via >>> RDBO? >> >> If you're feeling daring, this API is still not public, but I'm >> pretty >> sure it still works: >> >> http://www.mail-archive.com/rose-db-object@lists.sourceforge.net/ >> msg00710.html >> >> I haven't change it in a long time so it'll probably just become >> public eventually, assuming I haven't made any fatal mistakes in the >> API. If you try it, let me know how it works for you. >> >> As for doing it client-side in Perl... >> >>> as an alternate solution, i am considering doing all the de/cryption >>> work in perl, with the idea that i can inflate/deflate columns using >>> RDBO triggers, but this part has me worried (re: inflate, deflate >>> triggers): >>> >>>Note that the value to be inflated may have come from the >>> database, or from end-user code. Be prepared to handle almost >>> anything. >>> >>> since the de/crypt should only happen with values to/from the db, >>> not >>> from end-user code. >> >> That's no problem, you just have to be "prepared" to handle both >> cases >> :) You can detect where data is coming from and going to by using >> the >> is_loading() and is_saving() utility functions: >> >> http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Util.pm >> >> Then just do the appropriate thing in each situation. >> >> -John >> >> - >> - >> --- >> Take Surveys. Earn Cash. Influence the Future of IT >> Join SourceForge.net's Techsay panel and you'll get the chance to >> share your >> opinions on IT & business topics through brief surveys-and earn cash >> http://www.techsay.com/default.php? >> page=join.php&p=sourceforge&CID=DEVDEV >> ___ >> Rose-db-object mailing list >> Rose-db-object@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/rose-db-object > > --- > michael reece :: software engineer :: [EMAIL PROTECTED] > > > > ---------- > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php? > page=join.php&p=sourceforge&CID=DEVDEV > ___ > Rose-db-object mailing list > Rose-db-object@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rose-db-object --- michael reece :: software engineer :: [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] inflating/deflating columns using mysql functions
making some progress, but it appears select_sql doesn't get triggered when fetching lazy=>1 columns. On Feb 28, 2007, at 1:47 PM, John Siracusa wrote: > On 2/28/07, Michael Reece <[EMAIL PROTECTED]> wrote: >> is it possible to inflate/deflate columns using mysql functions via >> RDBO? > > If you're feeling daring, this API is still not public, but I'm pretty > sure it still works: > > http://www.mail-archive.com/rose-db-object@lists.sourceforge.net/ > msg00710.html > > I haven't change it in a long time so it'll probably just become > public eventually, assuming I haven't made any fatal mistakes in the > API. If you try it, let me know how it works for you. > > As for doing it client-side in Perl... > >> as an alternate solution, i am considering doing all the de/cryption >> work in perl, with the idea that i can inflate/deflate columns using >> RDBO triggers, but this part has me worried (re: inflate, deflate >> triggers): >> >>Note that the value to be inflated may have come from the >> database, or from end-user code. Be prepared to handle almost >> anything. >> >> since the de/crypt should only happen with values to/from the db, not >> from end-user code. > > That's no problem, you just have to be "prepared" to handle both cases > :) You can detect where data is coming from and going to by using the > is_loading() and is_saving() utility functions: > > http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Util.pm > > Then just do the appropriate thing in each situation. > > -John > > -- > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php? > page=join.php&p=sourceforge&CID=DEVDEV > ___ > Rose-db-object mailing list > Rose-db-object@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rose-db-object --- michael reece :: software engineer :: [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] inflating/deflating columns using mysql functions
this looks very promising! but what args are passed to select_sql, etc? that is, from RM::DB::Column::AESCrypt sub select_sql, how can i inspect the row/object to use its special crypt key? On Feb 28, 2007, at 1:47 PM, John Siracusa wrote: > On 2/28/07, Michael Reece <[EMAIL PROTECTED]> wrote: >> is it possible to inflate/deflate columns using mysql functions via >> RDBO? > > If you're feeling daring, this API is still not public, but I'm pretty > sure it still works: > > http://www.mail-archive.com/rose-db-object@lists.sourceforge.net/ > msg00710.html > > I haven't change it in a long time so it'll probably just become > public eventually, assuming I haven't made any fatal mistakes in the > API. If you try it, let me know how it works for you. > > As for doing it client-side in Perl... > >> as an alternate solution, i am considering doing all the de/cryption >> work in perl, with the idea that i can inflate/deflate columns using >> RDBO triggers, but this part has me worried (re: inflate, deflate >> triggers): >> >>Note that the value to be inflated may have come from the >> database, or from end-user code. Be prepared to handle almost >> anything. >> >> since the de/crypt should only happen with values to/from the db, not >> from end-user code. > > That's no problem, you just have to be "prepared" to handle both cases > :) You can detect where data is coming from and going to by using the > is_loading() and is_saving() utility functions: > > http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Util.pm > > Then just do the appropriate thing in each situation. > > -John > > -- > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php? > page=join.php&p=sourceforge&CID=DEVDEV > ___ > Rose-db-object mailing list > Rose-db-object@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rose-db-object --- michael reece :: software engineer :: [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] inflating/deflating columns using mysql functions
is it possible to inflate/deflate columns using mysql functions via RDBO? that is, consider the following behavior: mysql> create table special ( id int auto_increment primary key, secret blob ) ; Query OK, 0 rows affected (0.00 sec) mysql> insert into special (secret) values (AES_ENCRYPT('hello world', 'SECRET')) ; Query OK, 1 row affected (0.00 sec) mysql> select id, AES_DECRYPT(secret, 'SECRET') as secret from special where id=1 ; ++-+ | id | secret | ++-+ | 1 | hello world | ++-+ 1 row in set (0.00 sec) i would like a way to specify the magic in-db formula for getting/ setting this column, using a (non-db-related) accessor (ie, not constant for all rows) to generate the 'SECRET' portion of the function. i've read through the docs for Rose::DB::Object::Metadata::Column but don't see a solution. any suggestions about how to approach this? as an alternate solution, i am considering doing all the de/cryption work in perl, with the idea that i can inflate/deflate columns using RDBO triggers, but this part has me worried (re: inflate, deflate triggers): Note that the value to be inflated may have come from the database, or from end-user code. Be prepared to handle almost anything. since the de/crypt should only happen with values to/from the db, not from end-user code. - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Last call before 0.761
i am curious, if you "set sql_mode=strict_trans_tables;", what happens if you "insert into bars set id=1;" (with the original schema that had an id column, of course)? does it give the "cannot be null" error? (i don't have mysql 5.0.2+ installed and strict_trans_tables is not an option for 4.1.7) On Feb 21, 2007, at 12:50 PM, Ask Bjørn Hansen wrote: > > On Feb 21, 2007, at 12:35, Michael Reece wrote: > >>> MySQL, correctly, says the default is NULL: >> >> i was say erroneously, not correctly. >> >> if you try this: >> >>insert into bars set id=1 ; >>select * from bars ; >> >> you will see that the foo column is '', not NULL, suggesting the >> default really is ''. > > You got the SQL_MODE setting "wrong". :-) > > set sql_mode=strict_trans_tables; > > CREATE TABLE `bars` ( `foo` varchar(255) NOT NULL ) ENGINE=InnoDB; > Query OK, 0 rows affected (0.02 sec) > > insert into bars (foo) values (NULL); > ERROR 1048 (23000): Column 'foo' cannot be null > > > - ask > > -- > http://develooper.com/ - http://askask.com/ > > > > -- > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php? > page=join.php&p=sourceforge&CID=DEVDEV > ___ > Rose-db-object mailing list > Rose-db-object@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rose-db-object --- michael reece :: software engineer :: [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Last call before 0.761
> MySQL, correctly, says the default is NULL: i was say erroneously, not correctly. if you try this: insert into bars set id=1 ; select * from bars ; you will see that the foo column is '', not NULL, suggesting the default really is ''. On Feb 21, 2007, at 11:44 AM, Ask Bjørn Hansen wrote: > > On Feb 21, 2007, at 10:00, John Siracusa wrote: > >> I'm going to release 0.761 shortly. If you have any outstanding bugs >> not fixed in SVN or any other small suggestions, speak now... > > Maybe this is something, once again, that I am doing wrong - but I > don't understand this: > > mysql 5.0.27 and DBD::mysql 3.0008: > > create table bars (id int unsigned not null primary key, foo varchar > (255) not null) engine = InnoDB; > > gets me (with the auto loader): > > __PACKAGE__->meta->setup( >table => 'bars', > >columns => [ > id => { type => 'integer', not_null => 1 }, > foo => { type => 'varchar', default => '', length => 255, > not_null => 1 }, >], > >primary_key_columns => [ 'id' ], > ); > > Note the "" default to "foo". > > > mysql> show create table bars\G > *** 1. row *** > Table: bars > Create Table: CREATE TABLE `bars` ( >`id` int(10) unsigned NOT NULL, >`foo` varchar(255) NOT NULL, >PRIMARY KEY (`id`) > ) ENGINE=InnoDB DEFAULT CHARSET=latin1 > > mysql> select * from information_schema.columns where table_schema = > 'ntppool' and table_name = 'bars' and column_name = 'foo' \G > *** 1. row *** > TABLE_CATALOG: NULL > TABLE_SCHEMA: ntppool >TABLE_NAME: bars > COLUMN_NAME: foo > ORDINAL_POSITION: 2 >COLUMN_DEFAULT: NULL > IS_NULLABLE: NO > DATA_TYPE: varchar > CHARACTER_MAXIMUM_LENGTH: 255 >CHARACTER_OCTET_LENGTH: 255 > NUMERIC_PRECISION: NULL > NUMERIC_SCALE: NULL >CHARACTER_SET_NAME: latin1 >COLLATION_NAME: latin1_swedish_ci > COLUMN_TYPE: varchar(255) >COLUMN_KEY: > EXTRA: >PRIVILEGES: select,insert,update,references >COLUMN_COMMENT: > 1 row in set (0.03 sec) > > > - ask > > -- > http://develooper.com/ - http://askask.com/ > > > > -- > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php? > page=join.php&p=sourceforge&CID=DEVDEV > ___ > Rose-db-object mailing list > Rose-db-object@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rose-db-object --- michael reece :: software engineer :: [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] incorrect column type for "double precision"?
in a postgres table, i have a column lat| double precision the column definitions spit out from $class->meta- >perl_class_definition interpreted this as lat=> { type => 'scalar', length => 8 }, but RDBOM carps get_objects() - Vinq::RDBO::Image: Value for lat() is too long. Maximum length is 8 characters. Value is 16 characters: 37.3960614524039 at /usr/local/lib/perl5/site_perl/5.8.8/Rose/ Object.pm line 25 any suggestions for the proper type to declare for double precision columns? % perl -MRose::DB::Object -MRose::DB::Object::Manager -e 'print "RDBO: $Rose::DB::Object::VERSION; RDBOM:: $Rose::DB::Object::Manager::VERSION\n"' RDBO: 0.760; RDBOM:: 0.759 - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] timezone for magical 'now' value in datetime columns
if i do something like $obj->my_date('now'); $obj->save; i get UTC times. i see that i can define the column as saved_on => { type => 'datetime', time_zone => 'America/New_York' } and get the right datetime value, but is there an easy way to influence the timezone on all DateTime objects created by Rose::DB::Object? --- michael reece :: software engineer :: [EMAIL PROTECTED] - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] overloading Rose::DB->dbh
thanks, jonathan. that is (roughly) the approach i tried after sending my last mail, package Vinq::RDBO::_mysql; use base 'Rose::DB::Object'; use strict; use warnings; use Vinq::Globals qw($dbh); use Vinq::RDB::MySQL; our $MAKING_CLASSES = 0; sub init_db { my $_dbh = $dbh;# Global if ($MAKING_CLASSES) { ## RDBO has trouble auto_initializing from Vinq::DB, so get 'pure' dbh $dbh->_connect if $dbh->{connectionNeeded}; $_dbh = $dbh->{connectionHandle}; } my $db = Vinq::RDB::MySQL->new(driver => 'mysql', dbh => $_dbh); return $db; } 1; and then Vinq::RDBO::User (et al) isa Vinq::RDBO::_mysql. so far so good! On Feb 8, 2007, at 4:41 PM, Jonathan Vanasco wrote: > > On Feb 8, 2007, at 7:24 PM, Michael Reece wrote: > >> trying every which way to make Rose::DB::Object(s) always use my >> custom global $dbh, >> > > i have no idea why your package isn't working (i have a few ideas, > but no time to test) > > i suggest trying this approach, which is essentially what i do: > > package Vinq::RDB::Object; > use Vinq:: Globals (); > use Vinq::RDB::MySQL (); > use Rose::DB::Object (); > use base qw(Rose::DB::Object); > > sub init_db { > my $db= Vinq::RDB::MySQL->new(); > $db->dbh( $Vinq::Globals::dbh ); > return $db; > }; > > Then have objects inherit from Vinq::RDB::Object instead of > Rose::DB::Object. > > My system is different, I keep a 'bad' dbh by default and stuff a > valid dbh manually after i get a read/write/config dbh from a factory > class. > > // Jonathan Vanasco --- michael reece :: software engineer :: [EMAIL PROTECTED] - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] overloading Rose::DB->dbh
trying every which way to make Rose::DB::Object(s) always use my custom global $dbh, package Vinq::RDB::MySQL; use base 'Rose::DB'; use Vinq::Globals qw( $dbh ); __PACKAGE__->use_private_registry; __PACKAGE__->register_db(driver => 'mysql'); sub dbh { $dbh } sub driver { 'mysql' } 1; things were working great until i tried to $junk->add_stuff({ name => 'stuff 1' }); $junk->save; which leads to a '$db->commit or die $db->error;', but commit() says (in Rose/DB.pm): sub commit { my($self) = shift; return 0 unless(defined $self->{'dbh'} && $self->{'dbh'} {'Active'}); my $dbh = $self->dbh or return undef; ... but while $self->dbh returns my $dbh, $self->{'dbh'} hasn't been set so it dies (with no error). are there any docs/tutorials/testimonials about successfully using your own $dbh? - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] auto_initialize from custom $dbh
i am getting the following error when trying to auto_initialize a table class from a custom $dbh: Could not auto-retrieve primary key columns for class My::Junk - no primary key info found for catalog '' schema '' table 'junk' the table is very simple: mysql> create table junk ( junk_id int auto_increment primary key, name varchar(32) ) ; Query OK, 0 rows affected (0.09 sec) mysql> show create table junk\G *** 1. row *** Table: junk Create Table: CREATE TABLE `junk` ( `junk_id` int(11) NOT NULL auto_increment, `name` varchar(32) default NULL, PRIMARY KEY (`junk_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 1 row in set (0.00 sec) mysql> insert into junk set name = 'one' ; Query OK, 1 row affected (0.01 sec) mysql> insert into junk set name = 'two' ; Query OK, 1 row affected (0.00 sec) mysql> select * from junk ; +-+--+ | junk_id | name | +-+--+ | 1 | one | | 2 | two | +-+--+ 2 rows in set (0.01 sec) here is my test script: % cat auto.pl #!perl use strict; use warnings; ## Set up $dbh use Vinq::Globals qw($dbh); BEGIN { Vinq::Globals->init(confName => 'plexmreece') } BEGIN { ## verify $dbh is working my $sth = $dbh->prepare('SELECT COUNT(1) FROM junk'); $sth->execute; print "got ", $sth->fetchrow_array, " junks from dbh $dbh\n"; } package My::Junk; use base 'Rose::DB::Object'; use Vinq::Globals qw($dbh); sub init_db { print "Setting up Rose::DB with dbh => $dbh\n"; return Rose::DB->new(dbh => $dbh, driver => 'mysql'); } __PACKAGE__->meta->table('junk'); __PACKAGE__->meta->auto_initialize; and here is the output: % perl auto.pl got 2 junks from dbh Vinq::DB=HASH(0x8832a74) Setting up Rose::DB with dbh => Vinq::DB=HASH(0x8832a74) Setting up Rose::DB with dbh => Vinq::DB=HASH(0x8832a74) Setting up Rose::DB with dbh => Vinq::DB=HASH(0x8832a74) Could not auto-retrieve primary key columns for class My::Junk - no primary key info found for catalog '' schema '' table 'junk' at auto.pl line 28 am i missing something? do i need to tell Rose::DB more about the dbh i am injecting? % perl -MRose::DB -MRose::DB::Object -e 'print "Rose::DB $Rose::DB::VERSION\nRose::DB::Object $Rose::DB::Object::VERSION\n"' Rose::DB 0.732 Rose::DB::Object 0.760 - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
[RDBO] Manager classes?
do most users of RDBO tend to stick to the Thing and Thing::Manager pattern from the docs and tutorial? my $thing = Thing->new(...)->load; my @things = Thing::Manager->get_things(...); it seems like a lot of classes to juggle, when i'm looking at 100+ tables in the schema .. what headaches might one run into if the manager methods are created on the Thing class instead? my $thing = Thing->new(...)->load; my @things = Thing->get_things(...); alternatively, has anyone implemented a pattern using single manager class that manages all tables? my @those = TheOneTrue::Manager->get_those(); # returns Those objects my @these = TheOneTrue::Manager->get_these(); # returns These objects it seems like an intriguing idea, but what headaches might one run into with this approach? - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Rose::DB::Object thingy like class::dbi's set_sql?
All of that said, adding iterator options to get_objects_from_sql() and make_manager_method_from_sql() is pretty simple. If you really want it, I'll throw it in the next release :) yes, please! On Nov 28, 2006, at 1:33 PM, John Siracusa wrote: On 11/28/06, George Hartzell <[EMAIL PROTECTED]> wrote: It looks like I might be able to figure out how to get RDO::Manager to express the query, but it would be quicker (at least as a first cut to be able to do something like Foo::DB::Moose::Manager->get_iterator_from_sql(blahblahblah); I haven't seen anything in my dives into the docs. Is it possible? Can you give me a pointer? The get_objects_from_sql() Manager method will fetch objects based on hand-coded SQL: http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/ Manager.pm#get_objects_from_sql but it will return all the objects at once. Another Manager method, make_manager_method_from_sql(), will create a method based on your hand-coded SQL. This is a bit more like CDBI's set_sql method. http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/ Manager.pm#make_manager_method_from_sql But again, it returns all the objects at once. There's currently no iterator-based variant of those two methods. (Coming from CDBI, that shouldn't bother you too much, however, since the last time I checked, CDBI fetches all the rows from the database before allowing the first iteration anyway. The iterators used by the RDBO Manager, OTOH, fetch rows on demand, in response to each iteration.) All of that said, adding iterator options to get_objects_from_sql() and make_manager_method_from_sql() is pretty simple. If you really want it, I'll throw it in the next release :) -John -- --- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php? page=join.php&p=sourceforge&CID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object --- michael reece :: software engineer :: [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object