[RDBO] $object-related_iterator

2007-07-06 Thread Michael Reece
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


[RDBO] Rose::DB::Object::Column::Serialize?

2007-06-19 Thread Michael Reece

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

2007-06-11 Thread Michael Reece

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


Re: [RDBO] Namespace for 3rd-party RDBO modules

2007-05-23 Thread Michael Reece

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

2007-05-17 Thread Michael Reece
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


[RDBO] sort_by computed/aggregate column

2007-05-15 Thread Michael Reece
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] sort_by computed/aggregate column

2007-05-15 Thread Michael Reece

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


Re: [RDBO] sort_by computed/aggregate column

2007-05-15 Thread Michael Reece

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


[RDBO] re-using relationships with extra conditions

2007-05-11 Thread Michael Reece
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] re-using relationships with extra conditions

2007-05-11 Thread Michael Reece
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] auto_prime_caches, or common custom Metadata

2007-03-08 Thread Michael Reece
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.phpp=sourceforgeCID=DEVDEV
___
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

2007-03-08 Thread Michael Reece
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.phpp=sourceforgeCID=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.phpp=sourceforgeCID=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

2007-03-07 Thread Michael Reece

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.phpp=sourceforgeCID=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

2007-02-28 Thread Michael Reece
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.phpp=sourceforgeCID=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.phpp=sourceforgeCID=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

2007-02-28 Thread Michael Reece
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.phpp=sourceforgeCID=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.phpp=sourceforgeCID=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.phpp=sourceforgeCID=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

2007-02-21 Thread Michael Reece
 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.phpp=sourceforgeCID=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.phpp=sourceforgeCID=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?

2007-02-20 Thread Michael Reece
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.phpp=sourceforgeCID=DEVDEV
___
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

2007-02-08 Thread Michael Reece
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=lnkkid=120709bid=263057dat=121642
___
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

2007-02-08 Thread Michael Reece
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=lnkkid=120709bid=263057dat=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

2007-02-06 Thread Michael Reece
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=lnkkid=120709bid=263057dat=121642
___
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?

2006-11-28 Thread Michael Reece

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.phpp=sourceforgeCID=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.phpp=sourceforgeCID=DEVDEV___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object