Hello community, here is the log from the commit of package perl-Mojo-Pg for openSUSE:Factory checked in at 2017-11-07 09:57:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Mojo-Pg (Old) and /work/SRC/openSUSE:Factory/.perl-Mojo-Pg.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Mojo-Pg" Tue Nov 7 09:57:48 2017 rev:7 rq:538635 version:4.02 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Mojo-Pg/perl-Mojo-Pg.changes 2017-07-21 22:50:38.266245790 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Mojo-Pg.new/perl-Mojo-Pg.changes 2017-11-07 09:58:00.138293341 +0100 @@ -1,0 +2,10 @@ +Fri Nov 3 06:37:44 UTC 2017 - co...@suse.com + +- updated to 4.02 + see /usr/share/doc/packages/perl-Mojo-Pg/Changes + + 4.02 2017-11-02 + - Added delete_p, insert_p, query_p, select_p and update_p methods to + Mojo::Pg::Database. + +------------------------------------------------------------------- Old: ---- Mojo-Pg-4.01.tar.gz New: ---- Mojo-Pg-4.02.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Mojo-Pg.spec ++++++ --- /var/tmp/diff_new_pack.w09xQO/_old 2017-11-07 09:58:01.522243133 +0100 +++ /var/tmp/diff_new_pack.w09xQO/_new 2017-11-07 09:58:01.526242988 +0100 @@ -17,7 +17,7 @@ Name: perl-Mojo-Pg -Version: 4.01 +Version: 4.02 Release: 0 %define cpan_name Mojo-Pg Summary: Mojolicious ♥ PostgreSQL @@ -31,10 +31,10 @@ BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(DBD::Pg) >= 3.005001 -BuildRequires: perl(Mojolicious) >= 7.32 +BuildRequires: perl(Mojolicious) >= 7.51 BuildRequires: perl(SQL::Abstract) >= 1.81 Requires: perl(DBD::Pg) >= 3.005001 -Requires: perl(Mojolicious) >= 7.32 +Requires: perl(Mojolicious) >= 7.51 Requires: perl(SQL::Abstract) >= 1.81 %{perl_requires} ++++++ Mojo-Pg-4.01.tar.gz -> Mojo-Pg-4.02.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.01/Changes new/Mojo-Pg-4.02/Changes --- old/Mojo-Pg-4.01/Changes 2017-07-20 18:00:20.000000000 +0200 +++ new/Mojo-Pg-4.02/Changes 2017-11-02 19:41:32.000000000 +0100 @@ -1,4 +1,8 @@ +4.02 2017-11-02 + - Added delete_p, insert_p, query_p, select_p and update_p methods to + Mojo::Pg::Database. + 4.01 2017-07-20 - Decreased default max_connections from 5 to 1 in Mojo::Pg. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.01/MANIFEST.SKIP new/Mojo-Pg-4.02/MANIFEST.SKIP --- old/Mojo-Pg-4.01/MANIFEST.SKIP 2017-06-24 15:01:30.000000000 +0200 +++ new/Mojo-Pg-4.02/MANIFEST.SKIP 2017-07-28 12:05:39.000000000 +0200 @@ -5,3 +5,4 @@ ^MYMETA\. ^blib ^pm_to_blib +\B\.DS_Store diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.01/META.json new/Mojo-Pg-4.02/META.json --- old/Mojo-Pg-4.01/META.json 2017-07-20 18:01:43.000000000 +0200 +++ new/Mojo-Pg-4.02/META.json 2017-11-02 23:25:21.000000000 +0100 @@ -35,7 +35,7 @@ "runtime" : { "requires" : { "DBD::Pg" : "3.005001", - "Mojolicious" : "7.32", + "Mojolicious" : "7.51", "SQL::Abstract" : "1.81", "perl" : "5.010001" } @@ -57,6 +57,6 @@ }, "x_IRC" : "irc://irc.perl.org/#mojo" }, - "version" : "4.01", + "version" : "4.02", "x_serialization_backend" : "JSON::PP version 2.94" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.01/META.yml new/Mojo-Pg-4.02/META.yml --- old/Mojo-Pg-4.01/META.yml 2017-07-20 18:01:42.000000000 +0200 +++ new/Mojo-Pg-4.02/META.yml 2017-11-02 23:25:21.000000000 +0100 @@ -21,7 +21,7 @@ - t requires: DBD::Pg: '3.005001' - Mojolicious: '7.32' + Mojolicious: '7.51' SQL::Abstract: '1.81' perl: '5.010001' resources: @@ -30,5 +30,5 @@ homepage: http://mojolicious.org license: http://www.opensource.org/licenses/artistic-license-2.0 repository: https://github.com/kraih/mojo-pg.git -version: '4.01' +version: '4.02' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.01/Makefile.PL new/Mojo-Pg-4.02/Makefile.PL --- old/Mojo-Pg-4.01/Makefile.PL 2017-06-24 15:01:30.000000000 +0200 +++ new/Mojo-Pg-4.02/Makefile.PL 2017-11-02 19:10:49.000000000 +0100 @@ -30,6 +30,6 @@ }, }, PREREQ_PM => - {'DBD::Pg' => 3.005001, Mojolicious => '7.32', 'SQL::Abstract' => '1.81'}, + {'DBD::Pg' => 3.005001, Mojolicious => '7.51', 'SQL::Abstract' => '1.81'}, test => {TESTS => 't/*.t t/*/*.t'} ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.01/README.md new/Mojo-Pg-4.02/README.md --- old/Mojo-Pg-4.01/README.md 2017-06-24 15:01:30.000000000 +0200 +++ new/Mojo-Pg-4.02/README.md 2017-11-02 20:12:50.000000000 +0100 @@ -6,10 +6,8 @@ [Mojolicious](http://mojolicious.org) real-time web framework. ```perl -use Mojolicious::Lite; +use Mojolicious::Lite -signatures; use Mojo::Pg; -use 5.20.0; -use experimental 'signatures'; helper pg => sub { state $pg = Mojo::Pg->new('postgresql://postgres@/test') }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.01/lib/Mojo/Pg/Database.pm new/Mojo-Pg-4.02/lib/Mojo/Pg/Database.pm --- old/Mojo-Pg-4.01/lib/Mojo/Pg/Database.pm 2017-06-24 15:01:30.000000000 +0200 +++ new/Mojo-Pg-4.02/lib/Mojo/Pg/Database.pm 2017-11-02 19:40:46.000000000 +0100 @@ -18,6 +18,10 @@ my ($self, @cb) = (shift, ref $_[-1] eq 'CODE' ? pop : ()); return $self->query($self->pg->abstract->$name(@_), @cb); }; + monkey_patch __PACKAGE__, "${name}_p", sub { + my $self = shift; + return $self->query_p($self->pg->abstract->$name(@_)); + }; } sub DESTROY { @@ -109,6 +113,14 @@ $self->_watch; } +sub query_p { + my $self = shift; + my $promise = Mojo::IOLoop->delay; + $self->query( + @_ => sub { $_[1] ? $promise->reject($_[1]) : $promise->resolve($_[2]) }); + return $promise; +} + sub tables { my @tables = shift->dbh->tables('', '', '', ''); return [grep { $_ !~ /^(?:pg_catalog|information_schema)\./ } @tables]; @@ -290,6 +302,22 @@ # "delete from some_table where foo = 'bar' returning id" $db->delete('some_table', {foo => 'bar'}, {returning => 'id'}); +=head2 delete_p + + my $promise = $db->delete_p($table, \%where, \%options); + +Same as L</"delete">, but performs all operations non-blocking and returns a +L<Mojo::IOLoop::Delay> object to be used as a promise instead of accepting a +callback. + + $db->delete_p('some_table')->then(sub { + my $results = shift; + ... + })->catch(sub { + my $err = shift; + ... + })->wait; + =head2 disconnect $db->disconnect; @@ -336,6 +364,22 @@ # "insert into some_table (foo) values ('bar') returning id, foo" $db->insert('some_table', {foo => 'bar'}, {returning => ['id', 'foo']}); +=head2 insert_p + + my $promise = $db->insert_p($table, \@values || \%fieldvals, \%options); + +Same as L</"insert">, but performs all operations non-blocking and returns a +L<Mojo::IOLoop::Delay> object to be used as a promise instead of accepting a +callback. + + $db->insert_p(some_table => {foo => 'bar'})->then(sub { + my $results = shift; + ... + })->catch(sub { + my $err = shift; + ... + })->wait; + =head2 is_listening my $bool = $db->is_listening; @@ -403,6 +447,22 @@ use DBD::Pg ':pg_types'; $db->query('insert into bar values (?)', {type => PG_BYTEA, value => $bytes}); +=head2 query_p + + my $promise = $db->query_p('select * from foo'); + +Same as L</"query">, but performs all operations non-blocking and returns a +L<Mojo::IOLoop::Delay> object to be used as a promise instead of accepting a +callback. + + $db->query_p('insert into foo values (?, ?, ?)' => @values)->then(sub { + my $results = shift; + ... + })->catch(sub { + my $err = shift; + ... + })->wait; + =head2 select my $results = $db->select($source, $fields, $where, $order); @@ -435,6 +495,22 @@ # "select * from some_table where foo like '%test%'" $db->select('some_table', undef, {foo => {-like => '%test%'}}); +=head2 select_p + + my $promise = $db->select_p($source, $fields, $where, $order); + +Same as L</"select">, but performs all operations non-blocking and returns a +L<Mojo::IOLoop::Delay> object to be used as a promise instead of accepting a +callback. + + $db->select_p(some_table => ['foo'] => {bar => 'yada'})->then(sub { + my $results = shift; + ... + })->catch(sub { + my $err = shift; + ... + })->wait; + =head2 tables my $tables = $db->tables; @@ -481,6 +557,22 @@ # "update some_table set foo = 'bar' where id = 23 returning id" $db->update('some_table', {foo => 'bar'}, {id => 23}, {returning => 'id'}); +=head2 update_p + + my $promise = $db->update_p($table, \%fieldvals, \%where, \%options); + +Same as L</"update">, but performs all operations non-blocking and returns a +L<Mojo::IOLoop::Delay> object to be used as a promise instead of accepting a +callback. + + $db->update_p(some_table => {foo => 'baz'} => {foo => 'bar'})->then(sub { + my $results = shift; + ... + })->catch(sub { + my $err = shift; + ... + })->wait; + =head1 SEE ALSO L<Mojo::Pg>, L<Mojolicious::Guides>, L<http://mojolicious.org>. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.01/lib/Mojo/Pg/Results.pm new/Mojo-Pg-4.02/lib/Mojo/Pg/Results.pm --- old/Mojo-Pg-4.01/lib/Mojo/Pg/Results.pm 2017-06-24 15:01:30.000000000 +0200 +++ new/Mojo-Pg-4.02/lib/Mojo/Pg/Results.pm 2017-07-23 15:57:01.000000000 +0200 @@ -118,7 +118,7 @@ containing array references. # Process all rows at once - say $results->arrays->reduce(sub { $a->[3] + $b->[3] }); + say $results->arrays->reduce(sub { $a + $b->[3] }, 0); =head2 columns @@ -165,7 +165,7 @@ containing hash references. # Process all rows at once - say $results->hashes->reduce(sub { $a->{money} + $b->{money} }); + say $results->hashes->reduce(sub { $a + $b->{money} }, 0); =head2 new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.01/lib/Mojo/Pg.pm new/Mojo-Pg-4.02/lib/Mojo/Pg.pm --- old/Mojo-Pg-4.01/lib/Mojo/Pg.pm 2017-07-20 17:52:53.000000000 +0200 +++ new/Mojo-Pg-4.02/lib/Mojo/Pg.pm 2017-11-02 19:50:15.000000000 +0100 @@ -38,7 +38,7 @@ return $pubsub; }; -our $VERSION = '4.01'; +our $VERSION = '4.02'; sub db { $_[0]->database_class->new(dbh => $_[0]->_prepare, pg => $_[0]) } @@ -183,20 +183,17 @@ }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running; - # Concurrent non-blocking queries (synchronized with a delay) - Mojo::IOLoop->delay( - sub { - my $delay = shift; - $pg->db->query('select now() as now' => $delay->begin); - $pg->db->query('select * from names' => $delay->begin); - }, - sub { - my ($delay, $time_err, $time, $names_err, $names) = @_; - if (my $err = $time_err || $names_err) { die $err } - say $time->hash->{now}; - say $_->{name} for $names->hashes->each; - } - )->wait; + # Concurrent non-blocking queries (synchronized with promises) + my $now = $pg->db->query_p('select now() as now'); + my $names = $pg->db->query_p('select * from names'); + $now->all($names)->then(sub { + my ($now, $names) = @_; + say $now->[0]->hash->{now}; + say $_->{name} for $names->[0]->hashes->each; + })->catch(sub { + my $err = shift; + warn "Something went wrong: $err"; + })->wait; # Send and receive notifications non-blocking $pg->pubsub->listen(foo => sub { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.01/t/crud.t new/Mojo-Pg-4.02/t/crud.t --- old/Mojo-Pg-4.01/t/crud.t 2017-06-24 15:01:30.000000000 +0200 +++ new/Mojo-Pg-4.02/t/crud.t 2017-11-02 19:47:07.000000000 +0100 @@ -95,6 +95,43 @@ is_deeply $db->select('crud_test3')->hashes->to_array, [{id => 1, names => ['foo', 'bar', 'baz', 'yada']}], 'right structure'; +# Promises +$result = undef; +$pg->db->insert_p('crud_test', {name => 'promise'}, {returning => '*'}) + ->then(sub { $result = shift->hash })->wait; +is $result->{name}, 'promise', 'right result'; +$result = undef; +$db->select_p('crud_test', '*', {name => 'promise'}) + ->then(sub { $result = shift->hash })->wait; +is $result->{name}, 'promise', 'right result'; +$result = undef; +my $first = $pg->db->query_p("select * from crud_test where name = 'promise'"); +my $second = $pg->db->query_p("select * from crud_test where name = 'promise'"); +$first->all($second)->then( + sub { + my ($first, $second) = @_; + $result = [$first->[0]->hash, $second->[0]->hash]; + } +)->wait; +is $result->[0]{name}, 'promise', 'right result'; +is $result->[1]{name}, 'promise', 'right result'; +$result = undef; +$db->update_p( + 'crud_test', + {name => 'promise_two'}, + {name => 'promise'}, + {returning => '*'} +)->then(sub { $result = shift->hash })->wait; +is $result->{name}, 'promise_two', 'right result'; +$db->delete_p('crud_test', {name => 'promise_two'}, {returning => '*'}) + ->then(sub { $result = shift->hash })->wait; +is $result->{name}, 'promise_two', 'right result'; + +# Promises (rejected) +my $fail; +$db->dollar_only->query_p('does_not_exist')->catch(sub { $fail = shift })->wait; +like $fail, qr/does_not_exist/, 'right error'; + # Clean up once we are done $pg->db->query('drop schema mojo_crud_test cascade');