From gbjgiulio at gmail.com Mon Oct 4 06:49:16 2010 From: gbjgiulio at gmail.com (Giulio Bertani) Date: Mon, 4 Oct 2010 15:49:16 +0200 Subject: [Milan-pm] Incontro 2a settimana di Ottobre ... In-Reply-To: References: Message-ID: Really !!! Congratulation !!! I hope we could to a "little party" before you get marry !!! Have a nice WEDDING ! Giulio 2010/9/30 marcos rebelo > Hi > > With the time I forgot to write, Maxim will not be in Italy next week, > and for me it will complex to do it next week too, since I'm preparing > my matrimony. > > On Monday, I will create and send the Doodle invitation. > > Best Regards > Marcos Rebelo > > 2010/9/30 Giulio Bertani : > > Ciao Raga , > > non sentite un certo languore ... per l'incontro di Perl ??? :-D > > > > Settimana prossima inizio il corso di Perl e quindi inviter? i corsisti > ma > > ... quando si fa ? > > > > Io propongo nella settimana dal 12 - 15 Ottobre ... ( s? , Luned? non > > possiamo !!! ) > > > > Ce ne dite ? > > > > Ciao > > Giulio > > > > > > -- > > Giulio Bertani > > www.perquelliche.it (In definizione ...) > > > > _______________________________________________ > > Milan-pm mailing list > > Milan-pm at pm.org > > http://mail.pm.org/mailman/listinfo/milan-pm > > > > > > > > -- > Marcos Rebelo > http://oleber.freehostia.com > Milan Perl Mongers leader http://milan.pm.org > Webmaster of http://sites.google.com/site/oleberperlrecipes/ > _______________________________________________ > Milan-pm mailing list > Milan-pm at pm.org > http://mail.pm.org/mailman/listinfo/milan-pm > -- Giulio Bertani www.perquelliche.it (In definizione ...) -------------- next part -------------- An HTML attachment was scrubbed... URL: From oleber at gmail.com Mon Oct 4 07:09:00 2010 From: oleber at gmail.com (marcos rebelo) Date: Mon, 4 Oct 2010 16:09:00 +0200 Subject: [Milan-pm] Incontro 2a settimana di Ottobre ... In-Reply-To: References: Message-ID: Hy all The link for the voting is: http://www.doodle.com/xfuqr9m9iqm22fz3 The party will be next 30 of October in Portugal, do you want to come? Best Regards Marcos Rebelo 2010/10/4 Giulio Bertani : > Really !!! > Congratulation !!! > I hope we could to a "little party" before you get marry !!! > > Have a nice WEDDING ! > > Giulio > > 2010/9/30 marcos rebelo >> >> Hi >> >> With the time I forgot to write, Maxim will not be in Italy next week, >> and for me it will complex to do it next week too, since I'm preparing >> my matrimony. >> >> On Monday, I will create and send the Doodle invitation. >> >> Best Regards >> Marcos Rebelo >> >> 2010/9/30 Giulio Bertani : >> > Ciao Raga , >> > non sentite un certo languore ... per l'incontro di Perl ??? :-D >> > >> > Settimana prossima inizio il corso di Perl e quindi?inviter? i corsisti >> > ma >> > ... quando si fa ? >> > >> > Io propongo nella settimana dal 12 - 15 Ottobre ... ( s? , Luned? non >> > possiamo !!! ) >> > >> > Ce ne dite ? >> > >> > Ciao >> > Giulio >> > >> > >> > -- >> > Giulio Bertani >> > www.perquelliche.it (In definizione ...) >> > >> > _______________________________________________ >> > Milan-pm mailing list >> > Milan-pm at pm.org >> > http://mail.pm.org/mailman/listinfo/milan-pm >> > >> > >> >> >> >> -- >> Marcos Rebelo >> http://oleber.freehostia.com >> Milan Perl Mongers leader http://milan.pm.org >> Webmaster of http://sites.google.com/site/oleberperlrecipes/ >> _______________________________________________ >> Milan-pm mailing list >> Milan-pm at pm.org >> http://mail.pm.org/mailman/listinfo/milan-pm > > > > -- > Giulio Bertani > www.perquelliche.it (In definizione ...) > > _______________________________________________ > Milan-pm mailing list > Milan-pm at pm.org > http://mail.pm.org/mailman/listinfo/milan-pm > > -- Marcos Rebelo http://oleber.freehostia.com Milan Perl Mongers leader http://milan.pm.org Webmaster of http://perl5notebook.oleber.com From spleen.leveller at gmail.com Mon Oct 4 10:11:34 2010 From: spleen.leveller at gmail.com (Michele Valzelli) Date: Mon, 4 Oct 2010 19:11:34 +0200 Subject: [Milan-pm] Incontro 2a settimana di Ottobre ... In-Reply-To: References: Message-ID: Ciao, alcuni di voi gi? mi conoscono, e su loro pressione mi sono iscritto anch'io alla lista. E ho anche inserito le disponibilit? per venire all'incontro e conoscerci di persona. Michele On Mon, Oct 4, 2010 at 4:09 PM, marcos rebelo wrote: > Hy all > > The link for the voting is: http://www.doodle.com/xfuqr9m9iqm22fz3 > > The party will be next 30 of October in Portugal, do you want to come? > > Best Regards > Marcos Rebelo > > > 2010/10/4 Giulio Bertani : > > Really !!! > > Congratulation !!! > > I hope we could to a "little party" before you get marry !!! > > > > Have a nice WEDDING ! > > > > Giulio > > > > 2010/9/30 marcos rebelo > >> > >> Hi > >> > >> With the time I forgot to write, Maxim will not be in Italy next week, > >> and for me it will complex to do it next week too, since I'm preparing > >> my matrimony. > >> > >> On Monday, I will create and send the Doodle invitation. > >> > >> Best Regards > >> Marcos Rebelo > >> > >> 2010/9/30 Giulio Bertani : > >> > Ciao Raga , > >> > non sentite un certo languore ... per l'incontro di Perl ??? :-D > >> > > >> > Settimana prossima inizio il corso di Perl e quindi inviter? i > corsisti > >> > ma > >> > ... quando si fa ? > >> > > >> > Io propongo nella settimana dal 12 - 15 Ottobre ... ( s? , Luned? non > >> > possiamo !!! ) > >> > > >> > Ce ne dite ? > >> > > >> > Ciao > >> > Giulio > >> > > >> > > >> > -- > >> > Giulio Bertani > >> > www.perquelliche.it (In definizione ...) > >> > > >> > _______________________________________________ > >> > Milan-pm mailing list > >> > Milan-pm at pm.org > >> > http://mail.pm.org/mailman/listinfo/milan-pm > >> > > >> > > >> > >> > >> > >> -- > >> Marcos Rebelo > >> http://oleber.freehostia.com > >> Milan Perl Mongers leader http://milan.pm.org > >> Webmaster of http://sites.google.com/site/oleberperlrecipes/ > >> _______________________________________________ > >> Milan-pm mailing list > >> Milan-pm at pm.org > >> http://mail.pm.org/mailman/listinfo/milan-pm > > > > > > > > -- > > Giulio Bertani > > www.perquelliche.it (In definizione ...) > > > > _______________________________________________ > > Milan-pm mailing list > > Milan-pm at pm.org > > http://mail.pm.org/mailman/listinfo/milan-pm > > > > > > > > -- > Marcos Rebelo > http://oleber.freehostia.com > Milan Perl Mongers leader http://milan.pm.org > Webmaster of http://perl5notebook.oleber.com > _______________________________________________ > Milan-pm mailing list > Milan-pm at pm.org > http://mail.pm.org/mailman/listinfo/milan-pm > -- tell my friends I'm on vacation and say that I'm OK just wanna sleep all day -------------- next part -------------- An HTML attachment was scrubbed... URL: From oleber at gmail.com Mon Oct 4 13:10:51 2010 From: oleber at gmail.com (marcos rebelo) Date: Mon, 4 Oct 2010 22:10:51 +0200 Subject: [Milan-pm] Incontro 2a settimana di Ottobre ... In-Reply-To: References: Message-ID: It will be a pleasure to find you. 2010/10/4 Michele Valzelli : > Ciao, > alcuni di voi gi? mi conoscono, e su loro pressione mi sono iscritto anch'io > alla lista. E ho anche inserito le disponibilit? per venire all'incontro e > conoscerci di persona. > Michele > > On Mon, Oct 4, 2010 at 4:09 PM, marcos rebelo wrote: >> >> Hy all >> >> The link for the voting is: http://www.doodle.com/xfuqr9m9iqm22fz3 >> >> The party will be next 30 of October in Portugal, do you want to come? >> >> Best Regards >> Marcos Rebelo >> >> >> 2010/10/4 Giulio Bertani : >> > Really !!! >> > Congratulation !!! >> > I hope we could to a "little party" before you get marry !!! >> > >> > Have a nice WEDDING ! >> > >> > Giulio >> > >> > 2010/9/30 marcos rebelo >> >> >> >> Hi >> >> >> >> With the time I forgot to write, Maxim will not be in Italy next week, >> >> and for me it will complex to do it next week too, since I'm preparing >> >> my matrimony. >> >> >> >> On Monday, I will create and send the Doodle invitation. >> >> >> >> Best Regards >> >> Marcos Rebelo >> >> >> >> 2010/9/30 Giulio Bertani : >> >> > Ciao Raga , >> >> > non sentite un certo languore ... per l'incontro di Perl ??? :-D >> >> > >> >> > Settimana prossima inizio il corso di Perl e quindi?inviter? i >> >> > corsisti >> >> > ma >> >> > ... quando si fa ? >> >> > >> >> > Io propongo nella settimana dal 12 - 15 Ottobre ... ( s? , Luned? non >> >> > possiamo !!! ) >> >> > >> >> > Ce ne dite ? >> >> > >> >> > Ciao >> >> > Giulio >> >> > >> >> > >> >> > -- >> >> > Giulio Bertani >> >> > www.perquelliche.it (In definizione ...) >> >> > >> >> > _______________________________________________ >> >> > Milan-pm mailing list >> >> > Milan-pm at pm.org >> >> > http://mail.pm.org/mailman/listinfo/milan-pm >> >> > >> >> > >> >> >> >> >> >> >> >> -- >> >> Marcos Rebelo >> >> http://oleber.freehostia.com >> >> Milan Perl Mongers leader http://milan.pm.org >> >> Webmaster of http://sites.google.com/site/oleberperlrecipes/ >> >> _______________________________________________ >> >> Milan-pm mailing list >> >> Milan-pm at pm.org >> >> http://mail.pm.org/mailman/listinfo/milan-pm >> > >> > >> > >> > -- >> > Giulio Bertani >> > www.perquelliche.it (In definizione ...) >> > >> > _______________________________________________ >> > Milan-pm mailing list >> > Milan-pm at pm.org >> > http://mail.pm.org/mailman/listinfo/milan-pm >> > >> > >> >> >> >> -- >> Marcos Rebelo >> http://oleber.freehostia.com >> Milan Perl Mongers leader http://milan.pm.org >> Webmaster of http://perl5notebook.oleber.com >> _______________________________________________ >> Milan-pm mailing list >> Milan-pm at pm.org >> http://mail.pm.org/mailman/listinfo/milan-pm > > > > -- > tell my friends I'm on vacation > and say that I'm OK > just wanna sleep all day > > _______________________________________________ > Milan-pm mailing list > Milan-pm at pm.org > http://mail.pm.org/mailman/listinfo/milan-pm > > -- Marcos Rebelo http://oleber.freehostia.com Milan Perl Mongers leader http://milan.pm.org Webmaster of http://perl5notebook.oleber.com From oleber at gmail.com Tue Oct 5 05:11:01 2010 From: oleber at gmail.com (marcos rebelo) Date: Tue, 5 Oct 2010 14:11:01 +0200 Subject: [Milan-pm] New note on page5notebook Message-ID: Hi all I did one more note at: http://perl5notebook.oleber.com/objects/smart-selects-with-dynamic-response-to-undefiend-method-calls One example of the use of AUTOLOAD, to do some SQL dinamically. Comments are well come Best Regards Marcos Rebelo -- Marcos Rebelo http://oleber.freehostia.com Milan Perl Mongers leader http://milan.pm.org Webmaster of http://perl5notebook.oleber.com From casati_gianluca at yahoo.it Thu Oct 7 01:25:56 2010 From: casati_gianluca at yahoo.it (Gianluca Casati) Date: Thu, 7 Oct 2010 08:25:56 +0000 (GMT) Subject: [Milan-pm] New note on page5notebook In-Reply-To: References: Message-ID: <156152.1823.qm@web27904.mail.ukl.yahoo.com> I would use more $DBI::errstr after a prepare, an execute or a connect. Something like $dbh = DBI->connect( $NZ_SOURCE , $NZ_USER , $NZ_PASSWORD ) or die $log->abort( $connect_error_message . $DBI::errstr ); other than that is a very comfortable approach, even if I prefere to keep queries in separate .sql files under a sql directory so other people that don't know Perl can edit them ( after that they accept the '?' special character :) Bye, see you the next meeting ________________________________ Da: marcos rebelo A: milan-pm at pm.org; nl-pm at amsterdam.pm.org; perl-recipes at googlegroups.com; perl at lisbon.pm.org; Perl Begginers Inviato: Mar 5 ottobre 2010, 14:11:01 Oggetto: [Milan-pm] New note on page5notebook Hi all I did one more note at: http://perl5notebook.oleber.com/objects/smart-selects-with-dynamic-response-to-undefiend-method-calls One example of the use of AUTOLOAD, to do some SQL dinamically. Comments are well come Best Regards Marcos Rebelo -- Marcos Rebelo http://oleber.freehostia.com Milan Perl Mongers leader http://milan.pm.org Webmaster of http://perl5notebook.oleber.com _______________________________________________ Milan-pm mailing list Milan-pm at pm.org http://mail.pm.org/mailman/listinfo/milan-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From oleber at gmail.com Thu Oct 7 02:27:34 2010 From: oleber at gmail.com (marcos rebelo) Date: Thu, 7 Oct 2010 11:27:34 +0200 Subject: [Milan-pm] New note on page5notebook In-Reply-To: <156152.1823.qm@web27904.mail.ukl.yahoo.com> References: <156152.1823.qm@web27904.mail.ukl.yahoo.com> Message-ID: the Idea is to do fast work, FAST. If I just need one exception, DBI may do that to you. I seen this pattern to often eval { my $dbh = DBI->connect($dsn, $user, $password) or die $DBI::errstr; my $sth = $dbh->prepare("SELECT * FROM document WHERE id = ?") or die $DBI::errstr; $sth->execute($id) // die $DBI::errstr; my $hash = $sth->fetchrow_hashref; die $DBI::errstr if $DBI::errstr; ... }; if ($@) { ... } I prefer something like eval { my $dbh = DBI->connect($dsn, $user, $password, {'RaiseError' => 1}); my $sth = $dbh->prepare("SELECT * FROM document WHERE id = ?"); my $rs = $sth->execute($id); my $hash = $sth->fetchrow_hashref; ... }; if ($@) { ... } but for such a simple query, I would prefer eval { my $ss = SmartSelect->new($dsn, $user, $password); my $hash = $ss->select_document_by_id($id)->[0]; ... }; if ($@) { ... } For having this in a production environment, I would have to develop SmartSelect a little. Caching, more expressive queries, ... I didn't found this in CPAN, I didn't look for it so much, but I would use it. Like Einstein told: ?Any fool can make things bigger, more complex, and more violent. It takes a touch of genius-and a lot of courage-to move in the opposite direction.? Best Regards Marcos Rebelo 2010/10/7 Gianluca Casati : > > I would use more $DBI::errstr after a prepare, an execute or a connect. > Something like > > > $dbh = DBI->connect( $NZ_SOURCE , $NZ_USER , $NZ_PASSWORD ) or die > $log->abort( > $connect_error_message . $DBI::errstr ); > > other than that is a very comfortable approach, even if I prefere to keep > queries in separate .sql files under a sql directory so other people that > don't know Perl can edit them ( after that they accept the '?' special > character :) > > Bye, > > see you the next meeting > > ________________________________ > Da: marcos rebelo > A: milan-pm at pm.org; nl-pm at amsterdam.pm.org; perl-recipes at googlegroups.com; > perl at lisbon.pm.org; Perl Begginers > Inviato: Mar 5 ottobre 2010, 14:11:01 > Oggetto: [Milan-pm] New note on page5notebook > > Hi all > > I did one more note at: > > http://perl5notebook.oleber.com/objects/smart-selects-with-dynamic-response-to-undefiend-method-calls > > One example of the use of AUTOLOAD, to do some SQL dinamically. > > Comments are well come > > Best Regards > Marcos Rebelo > > -- > Marcos Rebelo > http://oleber.freehostia.com > Milan Perl Mongers leader http://milan.pm.org > Webmaster of http://perl5notebook.oleber.com > _______________________________________________ > Milan-pm mailing list > Milan-pm at pm.org > http://mail.pm.org/mailman/listinfo/milan-pm > > > _______________________________________________ > Milan-pm mailing list > Milan-pm at pm.org > http://mail.pm.org/mailman/listinfo/milan-pm > > -- Marcos Rebelo http://oleber.freehostia.com Milan Perl Mongers leader http://milan.pm.org Webmaster of http://perl5notebook.oleber.com From oha at oha.it Thu Oct 7 03:08:45 2010 From: oha at oha.it (Oha) Date: Thu, 07 Oct 2010 12:08:45 +0200 Subject: [Milan-pm] New note on page5notebook In-Reply-To: References: <156152.1823.qm@web27904.mail.ukl.yahoo.com> Message-ID: <4CAD9C2D.1010706@oha.it> On 10/07/2010 11:27 AM, marcos rebelo wrote: > but for such a simple query, I would prefer > > eval { > my $ss = SmartSelect->new($dsn, $user, $password); > my $hash = $ss->select_document_by_id($id)->[0]; > ... > }; > if ($@) { > ... > } > it's about 6 months i'm working on something like this, here a quick example: # obtain a single row from db my %row = select_uniq 'select * from foo where id = ?', $id; # when needed you may open a transaction tx_new { # if not differently specified, the default conenction will be used my %codes = select_map { $_{id} => $_{code} } 'SELECT * FROM codes'; if($code{0}) { tx_db 'master'; # going to use a specific connection my $new = select_uniq 'SELECT max(id)+1 FROM codes'; tx_do 'UPDATE codes SET id = ? WHERE id = 0', $new; } # now the connection is again the default, cauz tx_db got out of scope # transaction may be nested, connection will be kept separated tx_new { # if more then 1 rows is fetched, the following will confess my %foo = select_uniq 'SELECT * FROM codes WHERE id = ?', 'foo'; } } # connection will be committed and released, or rollbacked if an error is passing thru It is somewhat stable and i will probably put it on CPAN, but if you are interested i can share the code I'll gladly ear your thoughts about it. Oha From oleber at gmail.com Thu Oct 7 05:28:11 2010 From: oleber at gmail.com (marcos rebelo) Date: Thu, 7 Oct 2010 14:28:11 +0200 Subject: [Milan-pm] New note on page5notebook In-Reply-To: <4CAD9C2D.1010706@oha.it> References: <156152.1823.qm@web27904.mail.ukl.yahoo.com> <4CAD9C2D.1010706@oha.it> Message-ID: My idea is to throw away the SQL almost completely to 90% of the queries. When the queries are a little bit more complex, I'd prefer to create a View and use a simple interface. I never did a Project to CPAN, but If someone is interested in growing up the code I may help as much as I can +- 5 hours/week. Best Regards Marcos Rebelo On Thu, Oct 7, 2010 at 12:08 PM, Oha wrote: > On 10/07/2010 11:27 AM, marcos rebelo wrote: >> >> but for such a simple query, I would prefer >> >> eval { >> ? ?my $ss = SmartSelect->new($dsn, $user, $password); >> ? ?my $hash = $ss->select_document_by_id($id)->[0]; >> ? ?... >> }; >> if ($@) { >> ? ?... >> } >> > > it's about 6 months i'm working on something like this, here a quick > example: > > ? ? ? ?# obtain a single row from db > ? ? ? ?my %row = select_uniq 'select * from foo where id = ?', $id; > > ? ? ? ?# when needed you may open a transaction > ? ? ? ?tx_new > ? ? ? ?{ > ? ? ? ? ? ? ? ?# if not differently specified, the default conenction will > be used > ? ? ? ? ? ? ? ?my %codes = select_map { $_{id} => $_{code} } 'SELECT * FROM > codes'; > > ? ? ? ? ? ? ? ?if($code{0}) { > ? ? ? ? ? ? ? ? ? ? ? ?tx_db 'master'; # going to use a specific connection > > ? ? ? ? ? ? ? ? ? ? ? ?my $new = select_uniq 'SELECT max(id)+1 FROM codes'; > ? ? ? ? ? ? ? ? ? ? ? ?tx_do 'UPDATE codes SET id = ? WHERE id = 0', $new; > ? ? ? ? ? ? ? ?} > ? ? ? ? ? ? ? ?# now the connection is again the default, cauz tx_db got out > of scope > > ? ? ? ? ? ? ? ?# transaction may be nested, connection will be kept > separated > ? ? ? ? ? ? ? ?tx_new > ? ? ? ? ? ? ? ?{ > ? ? ? ? ? ? ? ? ? ? ? ?# if more then 1 rows is fetched, the following will > confess > ? ? ? ? ? ? ? ? ? ? ? ?my %foo = select_uniq 'SELECT * FROM codes WHERE id = > ?', 'foo'; > ? ? ? ? ? ? ? ?} > ? ? ? ?} # connection will be committed and released, or rollbacked if an > error is passing thru > > It is somewhat stable and i will probably put it on CPAN, but if you are > interested i can share the code > > I'll gladly ear your thoughts about it. > > Oha > _______________________________________________ > Milan-pm mailing list > Milan-pm at pm.org > http://mail.pm.org/mailman/listinfo/milan-pm > -- Marcos Rebelo http://oleber.freehostia.com Milan Perl Mongers leader http://milan.pm.org Webmaster of http://perl5notebook.oleber.com From casati_gianluca at yahoo.it Fri Oct 8 08:53:12 2010 From: casati_gianluca at yahoo.it (Gianluca Casati) Date: Fri, 8 Oct 2010 16:53:12 +0100 (BST) Subject: [Milan-pm] New note on page5notebook In-Reply-To: References: <156152.1823.qm@web27904.mail.ukl.yahoo.com> <4CAD9C2D.1010706@oha.it> Message-ID: <786255.53437.qm@web27901.mail.ukl.yahoo.com> Well Marcos, if you could help even just for a week to my CPAN project I would be really advantaged :) it is PNI and PNI::GUI on CPAN ________________________________ Da: marcos rebelo A: milan-pm at pm.org; nl-pm at amsterdam.pm.org; perl-recipes at googlegroups.com; perl at lisbon.pm.org; Perl Begginers Inviato: Gio 7 ottobre 2010, 14:28:11 Oggetto: Re: [Milan-pm] New note on page5notebook My idea is to throw away the SQL almost completely to 90% of the queries. When the queries are a little bit more complex, I'd prefer to create a View and use a simple interface. I never did a Project to CPAN, but If someone is interested in growing up the code I may help as much as I can +- 5 hours/week. Best Regards Marcos Rebelo On Thu, Oct 7, 2010 at 12:08 PM, Oha wrote: > On 10/07/2010 11:27 AM, marcos rebelo wrote: >> >> but for such a simple query, I would prefer >> >> eval { >> my $ss = SmartSelect->new($dsn, $user, $password); >> my $hash = $ss->select_document_by_id($id)->[0]; >> ... >> }; >> if ($@) { >> ... >> } >> > > it's about 6 months i'm working on something like this, here a quick > example: > > # obtain a single row from db > my %row = select_uniq 'select * from foo where id = ?', $id; > > # when needed you may open a transaction > tx_new > { > # if not differently specified, the default conenction will > be used > my %codes = select_map { $_{id} => $_{code} } 'SELECT * FROM > codes'; > > if($code{0}) { > tx_db 'master'; # going to use a specific connection > > my $new = select_uniq 'SELECT max(id)+1 FROM codes'; > tx_do 'UPDATE codes SET id = ? WHERE id = 0', $new; > } > # now the connection is again the default, cauz tx_db got out > of scope > > # transaction may be nested, connection will be kept > separated > tx_new > { > # if more then 1 rows is fetched, the following will > confess > my %foo = select_uniq 'SELECT * FROM codes WHERE id = > ?', 'foo'; > } > } # connection will be committed and released, or rollbacked if an > error is passing thru > > It is somewhat stable and i will probably put it on CPAN, but if you are > interested i can share the code > > I'll gladly ear your thoughts about it. > > Oha > _______________________________________________ > Milan-pm mailing list > Milan-pm at pm.org > http://mail.pm.org/mailman/listinfo/milan-pm > -- Marcos Rebelo http://oleber.freehostia.com Milan Perl Mongers leader http://milan.pm.org Webmaster of http://perl5notebook.oleber.com _______________________________________________ Milan-pm mailing list Milan-pm at pm.org http://mail.pm.org/mailman/listinfo/milan-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From oleber at gmail.com Mon Oct 11 03:06:17 2010 From: oleber at gmail.com (marcos rebelo) Date: Mon, 11 Oct 2010 12:06:17 +0200 Subject: [Milan-pm] Incontro 2a settimana di Ottobre ... In-Reply-To: References: Message-ID: Hi all This month I'm going to be the bad guy, since the election didn't give a clear choice. Saying this, the pizza will be next Thursday, the 14 of October at 20h in La Fabbrica Pizzeria. Vlale Pasubio, 2 http://www.lafabbricapizzeria.it Best Regards Marcos Rebelo On Mon, Oct 4, 2010 at 10:10 PM, marcos rebelo wrote: > It will be a pleasure to find you. > > 2010/10/4 Michele Valzelli : >> Ciao, >> alcuni di voi gi? mi conoscono, e su loro pressione mi sono iscritto anch'io >> alla lista. E ho anche inserito le disponibilit? per venire all'incontro e >> conoscerci di persona. >> Michele >> >> On Mon, Oct 4, 2010 at 4:09 PM, marcos rebelo wrote: >>> >>> Hy all >>> >>> The link for the voting is: http://www.doodle.com/xfuqr9m9iqm22fz3 >>> >>> The party will be next 30 of October in Portugal, do you want to come? >>> >>> Best Regards >>> Marcos Rebelo >>> >>> >>> 2010/10/4 Giulio Bertani : >>> > Really !!! >>> > Congratulation !!! >>> > I hope we could to a "little party" before you get marry !!! >>> > >>> > Have a nice WEDDING ! >>> > >>> > Giulio >>> > >>> > 2010/9/30 marcos rebelo >>> >> >>> >> Hi >>> >> >>> >> With the time I forgot to write, Maxim will not be in Italy next week, >>> >> and for me it will complex to do it next week too, since I'm preparing >>> >> my matrimony. >>> >> >>> >> On Monday, I will create and send the Doodle invitation. >>> >> >>> >> Best Regards >>> >> Marcos Rebelo >>> >> >>> >> 2010/9/30 Giulio Bertani : >>> >> > Ciao Raga , >>> >> > non sentite un certo languore ... per l'incontro di Perl ??? :-D >>> >> > >>> >> > Settimana prossima inizio il corso di Perl e quindi?inviter? i >>> >> > corsisti >>> >> > ma >>> >> > ... quando si fa ? >>> >> > >>> >> > Io propongo nella settimana dal 12 - 15 Ottobre ... ( s? , Luned? non >>> >> > possiamo !!! ) >>> >> > >>> >> > Ce ne dite ? >>> >> > >>> >> > Ciao >>> >> > Giulio >>> >> > >>> >> > >>> >> > -- >>> >> > Giulio Bertani >>> >> > www.perquelliche.it (In definizione ...) >>> >> > >>> >> > _______________________________________________ >>> >> > Milan-pm mailing list >>> >> > Milan-pm at pm.org >>> >> > http://mail.pm.org/mailman/listinfo/milan-pm >>> >> > >>> >> > >>> >> >>> >> >>> >> >>> >> -- >>> >> Marcos Rebelo >>> >> http://oleber.freehostia.com >>> >> Milan Perl Mongers leader http://milan.pm.org >>> >> Webmaster of http://sites.google.com/site/oleberperlrecipes/ >>> >> _______________________________________________ >>> >> Milan-pm mailing list >>> >> Milan-pm at pm.org >>> >> http://mail.pm.org/mailman/listinfo/milan-pm >>> > >>> > >>> > >>> > -- >>> > Giulio Bertani >>> > www.perquelliche.it (In definizione ...) >>> > >>> > _______________________________________________ >>> > Milan-pm mailing list >>> > Milan-pm at pm.org >>> > http://mail.pm.org/mailman/listinfo/milan-pm >>> > >>> > >>> >>> >>> >>> -- >>> Marcos Rebelo >>> http://oleber.freehostia.com >>> Milan Perl Mongers leader http://milan.pm.org >>> Webmaster of http://perl5notebook.oleber.com >>> _______________________________________________ >>> Milan-pm mailing list >>> Milan-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/milan-pm >> >> >> >> -- >> tell my friends I'm on vacation >> and say that I'm OK >> just wanna sleep all day >> >> _______________________________________________ >> Milan-pm mailing list >> Milan-pm at pm.org >> http://mail.pm.org/mailman/listinfo/milan-pm >> >> > > > > -- > Marcos Rebelo > http://oleber.freehostia.com > Milan Perl Mongers leader http://milan.pm.org > Webmaster of http://perl5notebook.oleber.com > -- Marcos Rebelo http://oleber.freehostia.com Milan Perl Mongers leader http://milan.pm.org Webmaster of http://perl5notebook.oleber.com From oleber at gmail.com Thu Oct 14 07:02:36 2010 From: oleber at gmail.com (marcos rebelo) Date: Thu, 14 Oct 2010 16:02:36 +0200 Subject: [Milan-pm] Incontro 2a settimana di Ottobre ... In-Reply-To: References: Message-ID: Hi all Just to remember, the Pizza is today. Best Regards Marcos Rebelo On Mon, Oct 11, 2010 at 12:06 PM, marcos rebelo wrote: > Hi all > > This month I'm going to be the bad guy, since the election didn't give > a clear choice. > > Saying this, the pizza will be next Thursday, the 14 of October at 20h > in La Fabbrica Pizzeria. > > Vlale Pasubio, 2 > > http://www.lafabbricapizzeria.it > > Best Regards > Marcos Rebelo > > > > On Mon, Oct 4, 2010 at 10:10 PM, marcos rebelo wrote: >> It will be a pleasure to find you. >> >> 2010/10/4 Michele Valzelli : >>> Ciao, >>> alcuni di voi gi? mi conoscono, e su loro pressione mi sono iscritto anch'io >>> alla lista. E ho anche inserito le disponibilit? per venire all'incontro e >>> conoscerci di persona. >>> Michele >>> >>> On Mon, Oct 4, 2010 at 4:09 PM, marcos rebelo wrote: >>>> >>>> Hy all >>>> >>>> The link for the voting is: http://www.doodle.com/xfuqr9m9iqm22fz3 >>>> >>>> The party will be next 30 of October in Portugal, do you want to come? >>>> >>>> Best Regards >>>> Marcos Rebelo >>>> >>>> >>>> 2010/10/4 Giulio Bertani : >>>> > Really !!! >>>> > Congratulation !!! >>>> > I hope we could to a "little party" before you get marry !!! >>>> > >>>> > Have a nice WEDDING ! >>>> > >>>> > Giulio >>>> > >>>> > 2010/9/30 marcos rebelo >>>> >> >>>> >> Hi >>>> >> >>>> >> With the time I forgot to write, Maxim will not be in Italy next week, >>>> >> and for me it will complex to do it next week too, since I'm preparing >>>> >> my matrimony. >>>> >> >>>> >> On Monday, I will create and send the Doodle invitation. >>>> >> >>>> >> Best Regards >>>> >> Marcos Rebelo >>>> >> >>>> >> 2010/9/30 Giulio Bertani : >>>> >> > Ciao Raga , >>>> >> > non sentite un certo languore ... per l'incontro di Perl ??? :-D >>>> >> > >>>> >> > Settimana prossima inizio il corso di Perl e quindi?inviter? i >>>> >> > corsisti >>>> >> > ma >>>> >> > ... quando si fa ? >>>> >> > >>>> >> > Io propongo nella settimana dal 12 - 15 Ottobre ... ( s? , Luned? non >>>> >> > possiamo !!! ) >>>> >> > >>>> >> > Ce ne dite ? >>>> >> > >>>> >> > Ciao >>>> >> > Giulio >>>> >> > >>>> >> > >>>> >> > -- >>>> >> > Giulio Bertani >>>> >> > www.perquelliche.it (In definizione ...) >>>> >> > >>>> >> > _______________________________________________ >>>> >> > Milan-pm mailing list >>>> >> > Milan-pm at pm.org >>>> >> > http://mail.pm.org/mailman/listinfo/milan-pm >>>> >> > >>>> >> > >>>> >> >>>> >> >>>> >> >>>> >> -- >>>> >> Marcos Rebelo >>>> >> http://oleber.freehostia.com >>>> >> Milan Perl Mongers leader http://milan.pm.org >>>> >> Webmaster of http://sites.google.com/site/oleberperlrecipes/ >>>> >> _______________________________________________ >>>> >> Milan-pm mailing list >>>> >> Milan-pm at pm.org >>>> >> http://mail.pm.org/mailman/listinfo/milan-pm >>>> > >>>> > >>>> > >>>> > -- >>>> > Giulio Bertani >>>> > www.perquelliche.it (In definizione ...) >>>> > >>>> > _______________________________________________ >>>> > Milan-pm mailing list >>>> > Milan-pm at pm.org >>>> > http://mail.pm.org/mailman/listinfo/milan-pm >>>> > >>>> > >>>> >>>> >>>> >>>> -- >>>> Marcos Rebelo >>>> http://oleber.freehostia.com >>>> Milan Perl Mongers leader http://milan.pm.org >>>> Webmaster of http://perl5notebook.oleber.com >>>> _______________________________________________ >>>> Milan-pm mailing list >>>> Milan-pm at pm.org >>>> http://mail.pm.org/mailman/listinfo/milan-pm >>> >>> >>> >>> -- >>> tell my friends I'm on vacation >>> and say that I'm OK >>> just wanna sleep all day >>> >>> _______________________________________________ >>> Milan-pm mailing list >>> Milan-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/milan-pm >>> >>> >> >> >> >> -- >> Marcos Rebelo >> http://oleber.freehostia.com >> Milan Perl Mongers leader http://milan.pm.org >> Webmaster of http://perl5notebook.oleber.com >> > > > > -- > Marcos Rebelo > http://oleber.freehostia.com > Milan Perl Mongers leader http://milan.pm.org > Webmaster of http://perl5notebook.oleber.com > -- Marcos Rebelo http://oleber.freehostia.com Milan Perl Mongers leader http://milan.pm.org Webmaster of http://perl5notebook.oleber.com From federico.baranzini at gmail.com Thu Oct 14 07:10:16 2010 From: federico.baranzini at gmail.com (Federico Baranzini) Date: Thu, 14 Oct 2010 16:10:16 +0200 Subject: [Milan-pm] pizzata milanese Message-ID: Ciao a tutti confermate la pizzata per questa sera ore 20 Fabbrica Pizza ? Federico -------------- next part -------------- An HTML attachment was scrubbed... URL: From minimal.oasis+milan-pm at gmail.com Thu Oct 14 07:22:53 2010 From: minimal.oasis+milan-pm at gmail.com (Max M.) Date: Thu, 14 Oct 2010 16:22:53 +0200 Subject: [Milan-pm] pizzata milanese In-Reply-To: References: Message-ID: 2010/10/14 Federico Baranzini : > confermate la pizzata per questa sera ore 20 Fabbrica Pizza ? La pizzata ? confermata. Max From gbjgiulio at gmail.com Thu Oct 14 07:33:11 2010 From: gbjgiulio at gmail.com (Giulio Bertani) Date: Thu, 14 Oct 2010 16:33:11 +0200 Subject: [Milan-pm] pizzata milanese In-Reply-To: References: Message-ID: Ciao , io ci sono e Marcos pure ... :-D 2010/10/14 Federico Baranzini > Ciao a tutti > > confermate la pizzata per questa sera ore 20 Fabbrica Pizza ? > > Federico > > _______________________________________________ > Milan-pm mailing list > Milan-pm at pm.org > http://mail.pm.org/mailman/listinfo/milan-pm > > -- Giulio Bertani www.perquelliche.it (In definizione ...) -------------- next part -------------- An HTML attachment was scrubbed... URL: From casati_gianluca at yahoo.it Sat Oct 23 06:09:24 2010 From: casati_gianluca at yahoo.it (Gianluca Casati) Date: Sat, 23 Oct 2010 14:09:24 +0100 (BST) Subject: [Milan-pm] test ok :-) Message-ID: <147795.168.qm@web27905.mail.ukl.yahoo.com> Ciao a tutti, volevo scrivervi per segnalarvi una curiosit? riguardo i test, dato che si tratta di un tema che vorrei approfondire il pi? possibile (Marcos mi ha "cazziato" dicendomi che prima si scrivono i test e poi il codice :-). Ho un modulo del tipo package Foo; use Moose; sub task{ print "ok\n" } 1 e un test del tipo use strict; use Test::More tests => 2; use_ok( 'Foo' ); # primo test ... my $foo = Foo->new(); ok( $foo->task() , 'il task ha girato' ); # secondo test ... # ... ma se faccio un prove -l mi dice che hanno girato TRE test !!!!!!!! la cosa mi ha parecchio sorpreso, anche perch? l' ho scoperta veramente per caso ( o meglio, per "sfiga" :-) infatti se avessi fatto print "occhei\n" al posto di print "ok\n" non avrei avuto problemi :-)))) . Un saluto a tutti, alla prossima pizzata. -------------- next part -------------- An HTML attachment was scrubbed... URL: From oleber at gmail.com Sat Oct 23 06:53:35 2010 From: oleber at gmail.com (marcos rebelo) Date: Sat, 23 Oct 2010 15:53:35 +0200 Subject: [Milan-pm] test ok :-) In-Reply-To: <147795.168.qm@web27905.mail.ukl.yahoo.com> References: <147795.168.qm@web27905.mail.ukl.yahoo.com> Message-ID: Hi It depends about how you are testing. if you do: #> perl Foo.t gives you 2 tests, if you do #> prove Foo.t gives you 3 tests The question is that prove parses the output of 'perl Foo.t'. if your code does prints, even this prints shall be tested since they are output. I usually use Test::Trap for the output Best Regards Marcos Rebelo 2010/10/23 Gianluca Casati : > Ciao a tutti, > > volevo scrivervi per segnalarvi una curiosit? riguardo i test, dato che si > tratta di un tema che vorrei approfondire il pi? possibile (Marcos mi ha > "cazziato" dicendomi che prima si scrivono i test e poi il codice :-). > > Ho un modulo del tipo > > package Foo; > use Moose; > sub task{ print "ok\n" } > 1 > > e un test del tipo > > use strict; > use Test::More tests => 2; > > use_ok( 'Foo' ); # primo test ... > my $foo = Foo->new(); > ok( $foo->task() , 'il task ha girato' ); # secondo test ... > > # ... ma se faccio un prove -l mi dice che hanno girato TRE test !!!!!!!! > > la cosa mi ha parecchio sorpreso, anche perch? l' ho scoperta veramente per > caso ( o meglio, per "sfiga" :-) > > infatti se avessi fatto print "occhei\n" al posto di print "ok\n" non avrei > avuto problemi :-)))) . > > Un saluto a tutti, > > alla prossima pizzata. > > > > > > _______________________________________________ > Milan-pm mailing list > Milan-pm at pm.org > http://mail.pm.org/mailman/listinfo/milan-pm > > -- Marcos Rebelo http://oleber.freehostia.com Milan Perl Mongers leader http://milan.pm.org Webmaster of http://perl5notebook.oleber.com From oleber at gmail.com Sat Oct 23 07:05:00 2010 From: oleber at gmail.com (marcos rebelo) Date: Sat, 23 Oct 2010 16:05:00 +0200 Subject: [Milan-pm] Actual status of smartSelect Message-ID: ####################################################### package SmartSelect; use strict; use warnings; use re 'eval'; our $VERSION = '0.0.1'; use Carp qw(confess); use Data::Dumper; sub new { my ($pkg, $dbh) = @_; return bless({'dbh' => $dbh, 'db_struct' => {}}, $pkg); } sub get_dbh { return shift->{'dbh'} } sub get_db_struct { return shift->{'db_struct'}} our $AUTOLOAD; sub AUTOLOAD { my ($self, @constrains) = @_; my $method = $AUTOLOAD; $method =~ s/.*::(.*)/$1/; return if $method eq 'DESTROY'; my $closure; $closure = shift(@constrains) if @constrains and ref($constrains[0]) eq 'CODE'; my $hash_args; $hash_args = shift(@constrains) if @constrains and ref($constrains[0]) eq 'HASH'; local $self->get_dbh->{'RaiseError'} = 1; my ($sql, $action) = @{$self->_parse($method, scalar @constrains)}; confess("Closure just accepted in execute") if $closure and $action ne 'EXECUTE'; confess("Hash just accepted in update or insert") if $hash_args and $action ne 'UPDATE' and $action ne 'INSERT'; if ( $action eq 'DELETE') { return $self->get_dbh->do($sql, undef, @constrains); } elsif ( $action eq 'UPDATE') { my $values_to_set = join(", ", map { "$_ = ?"} keys %{$hash_args}); $sql =~ s/<#>/SET $values_to_set/; return $self->get_dbh->do($sql, undef, values(%{$hash_args}), @constrains); } elsif ( $action eq 'INSERT') { my $values = join(", ", map { "?" } keys %{$hash_args}); my $names = join(", ", map { $_ } keys %{$hash_args}); $sql = "$sql ($names) VALUES ( $values )"; return $self->get_dbh->do($sql, undef, values(%{$hash_args})); } else { my $sth = $self->get_dbh->prepare($sql); my $rs = $sth->execute(@constrains); my @rows; while ( my $row = $sth->fetchrow_hashref ) { if ($action eq 'EXECUTE') { local $_ = $row; push(@rows, $closure->($row)); } else { push(@rows, $row); } } return \@rows; } } sub _parse { my ($self, $text, $count) = @_; my $self_db_struct = $self->get_db_struct; if ( not keys %{$self_db_struct}) { my $sth = $self->get_dbh->table_info; while ( my $row = $sth->fetchrow_hashref) { if ($row->{'TABLE_TYPE'} eq 'TABLE' or $row->{'TABLE_TYPE'} eq 'VIEW') { $self_db_struct->{$row->{'TABLE_NAME'}} = undef; } } } my @tables = keys %{$self_db_struct}; my $re_tables = '(?:' . join( '|', @tables ) . ')'; my ($action, $table, $constraints, @used_columns) = do { my $re_columns; local *closure = sub { my ($action, $table) = @_; $re_columns = ($action eq 'insert') ? "" : $self->_regexp_for_table($table, $count); return $re_columns; }; my $extra_re = $count ? qr/(?:_by_((??{closure($1, $2)})))/ : qr//; my $full_re = qr/^(select|execute|delete|update|insert)_($re_tables)$extra_re$/; { # I don't know why but I need the next line $text =~ $full_re; } my @table_info = ($text =~ $full_re); my @column_info = ( $count and @table_info ) ? ( $table_info[-1] =~ /^$re_columns$/ ) : (); (@table_info, @column_info); }; confess "No match for '$text' with $count columns" if not defined $table; $action = uc $action; my $sql = $action eq 'DELETE' ? "DELETE FROM $table" : $action eq 'UPDATE' ? "UPDATE $table <#>" : $action eq 'INSERT' ? "INSERT INTO $table" : "SELECT * FROM $table"; if ( $count ) { $sql = "$sql WHERE " . join(' AND ', map {"$_ = ?"} @used_columns); } return [$sql, $action]; } sub _regexp_for_table { my ($self, $table, $column_count) = @_; my $self_db_struct = $self->get_db_struct; if ( not defined $self_db_struct->{$table} ) { @{$self_db_struct->{$table}} = keys %{$self->get_dbh->column_info( undef, undef, $table, undef )->fetchall_hashref('COLUMN_NAME')}; } my @columns = @{$self_db_struct->{$table}}; my $re_column = '(?:' . join('|', @columns) . ')'; my $re_columns = join('_', map { "($re_column)" } 1 .. $column_count); return qr/$re_columns/; } 1; ####################################################### and its tests ####################################################### #!perl use strict; use warnings; use Test::More; use Test::Exception; use Test::Deep; use Data::Dumper; use DBI; use Readonly 'Readonly'; Readonly my $PKG => 'SmartSelect'; use File::Temp 'tempdir'; my $tempdir = tempdir('CLEANUP' => 1); my $tempdb = "$tempdir/db.sqlite"; my $dbh = DBI->connect("dbi:SQLite:dbname=:memory:","",""); $dbh->do('CREATE TABLE document (id, name)'); $dbh->do('INSERT INTO document(id, name) VALUES (?, ?)', undef, 'doc1', 'document 1'); $dbh->do('INSERT INTO document(id, name) VALUES (?, ?)', undef, 'doc2', 'document 2'); $dbh->do('CREATE TABLE person (id, name, country)'); $dbh->do('INSERT INTO person(id, name, country) VALUES (?, ?, ?)', undef, 'p1', 'John', 'USA'); $dbh->do('INSERT INTO person(id, name, country) VALUES (?, ?, ?)', undef, 'p2', 'Marcos', 'PT'); $dbh->do('INSERT INTO person(id, name, country) VALUES (?, ?, ?)', undef, 'p3', 'Maria', 'PT'); $dbh->do("CREATE VIEW portuguese_person AS SELECT * FROM person WHERE country = 'PT'") or die $dbh->err; use_ok($PKG); my $obj = $PKG->new($dbh); isa_ok($obj, $PKG); isa_ok($obj, 'SmartSelect'); is_deeply( $obj->get_db_struct, {}, 'db_struct correctly started'); can_ok($obj, '_parse'); cmp_deeply($obj->_parse('select_document', 0), ['SELECT * FROM document', 'SELECT'], 'select all table'); cmp_deeply($obj->get_db_struct, { 'document' => undef, 'person' => undef, 'portuguese_person' => undef }, 'db_struct correctly created'); throws_ok { $obj->_parse('select_other', 0) } qr/No match for 'select_other' with 0 columns at /, 'Fail with unreconizable table'; throws_ok { $obj->_parse('select_document', 1) } qr/No match for 'select_document' with 1 columns at /, 'Fail expecting 1 column'; throws_ok { $obj->_parse('select_person_by_id', 0) } qr/No match for 'select_person_by_id' with 0 columns at /, 'Fail expecting no column'; cmp_deeply($obj->_parse('execute_person_by_id', 1), ['SELECT * FROM person WHERE id = ?', 'EXECUTE'], 'select by id'); cmp_deeply($obj->_parse('select_person_by_name_id', 2), ['SELECT * FROM person WHERE name = ? AND id = ?', 'SELECT'], 'select by name id'); cmp_deeply($obj->get_db_struct, { 'document' => undef, 'person' => bag('id', 'name', 'country'), 'portuguese_person' => undef }, 'db_struct correctly maintained'); cmp_deeply($obj->_parse('select_portuguese_person_by_id', 1), ['SELECT * FROM portuguese_person WHERE id = ?', 'SELECT'], 'select by name id'); cmp_deeply($obj->get_db_struct, { 'document' => undef, 'person' => bag('id', 'name', 'country'), 'portuguese_person' => bag('id', 'name', 'country') }, 'db_struct correctly maintained'); throws_ok { $obj->_parse('select_document_by_country', 1) } qr/No match for 'select_document_by_country' with 1 columns at /, 'Fail with unrecognizable column'; cmp_deeply($obj->get_db_struct, { 'document' => bag('id', 'name'), 'person' => bag('id', 'name', 'country'), 'portuguese_person' => bag('id', 'name', 'country') }, 'db_struct correctly maintained'); cmp_deeply($obj->_parse('delete_person', 0), ['DELETE FROM person', 'DELETE'], '_parse delete_person'); cmp_deeply($obj->_parse('delete_person_by_id', 1), ['DELETE FROM person WHERE id = ?', 'DELETE'], '_parse delete_person_by_id'); cmp_deeply($obj->_parse('update_person', 0), ['UPDATE person <#>', 'UPDATE'], '_parse update_person'); cmp_deeply($obj->_parse('update_person_by_id', 1), ['UPDATE person <#> WHERE id = ?', 'UPDATE'], '_parse update_person_by_id'); cmp_deeply($obj->_parse('insert_person', 0), ['INSERT INTO person', 'INSERT'], '_parse insert_person'); throws_ok { $obj->_parse('insert_person_by_id', 1) } qr/No match for 'insert_person_by_id' with 1 columns/; cmp_deeply( $obj->select_document_by_id('doc2'), [{'id' => 'doc2', 'name' => 'document 2'}], '1 record selected in document' ); cmp_deeply( $obj->select_document, bag( {'id' => 'doc1', 'name' => 'document 1'}, {'id' => 'doc2', 'name' => 'document 2'} ), '2 record selected in document' ); cmp_deeply($obj->execute_person_by_country( sub { is($dbh->{'RaiseError'}, 1, 'RaiseError activated'); return shift->{'name'}; }, 'PT'), bag('Marcos', 'Maria'), 'execute with parameter in closure'); { my @names; $obj->execute_person_by_country(sub {push(@names, shift->{'name'})}, 'PT'); cmp_deeply(\@names, bag('Marcos', 'Maria'), 'execute with parameter in \$_'); } throws_ok { $obj->select_person_by_country(sub {}, 'PT') } qr/Closure just accepted in execute at /, 'Fail with Closure in SELECT'; throws_ok { $obj->update_person_by_country(sub {}, 'PT') } qr/Closure just accepted in execute at /, 'Fail with Closure in UPDATE'; throws_ok { $obj->delete_person_by_country(sub {}, 'PT') } qr/Closure just accepted in execute at /, 'Fail with Closure in DELETE'; throws_ok { $obj->select_person_by_country({}, 'PT') } qr/Hash just accepted in update or insert at /, 'Fail with Hash in SELECT'; throws_ok { $obj->execute_person_by_country({}, 'PT') } qr/Hash just accepted in update or insert at /, 'Fail with Hash in EXECUTE'; throws_ok { $obj->delete_person_by_country({}, 'PT') } qr/Hash just accepted in update or insert at /, 'Fail with Hash in DELETE'; { local $dbh->{'PrintError'} = 0; local $obj->get_db_struct->{'document'} = ['pippo']; throws_ok {$obj->select_document_by_pippo('PT')} qr/prepare/; } { is($obj->delete_person_by_country('PT'), 2, 'Delete returned the number of deleted rows'); cmp_deeply($obj->select_person,[{'id' => 'p1', 'name' => 'John', 'country' => 'USA'}], 'Delete deleted the rows'); } { $obj->insert_person({'id' => 'p2', 'name' => 'Marcos', 'country' => 'PT'}); $obj->insert_person({'id' => 'p3', 'name' => 'Maria', 'country' => 'PT'}); cmp_deeply( $obj->select_person, bag( {'id' => 'p1', 'name' => 'John', 'country' => 'USA'}, {'id' => 'p2', 'name' => 'Marcos', 'country' => 'PT'} , {'id' => 'p3', 'name' => 'Maria', 'country' => 'PT'}), 'UPDATE updated the rows'); } { is($obj->update_person_by_country({'country' => 'IT'} , 'PT'), 2, 'UPDATE returned the number of deleted rows'); cmp_deeply( $obj->select_person, bag( {'id' => 'p1', 'name' => 'John', 'country' => 'USA'}, {'id' => 'p2', 'name' => 'Marcos', 'country' => 'IT'} , {'id' => 'p3', 'name' => 'Maria', 'country' => 'IT'}), 'UPDATE updated the rows'); } done_testing; -- Marcos Rebelo http://oleber.freehostia.com Milan Perl Mongers leader http://milan.pm.org Webmaster of http://perl5notebook.oleber.com