Hello community,

here is the log from the commit of package perl-Mojo-Pg for openSUSE:Factory 
checked in at 2017-07-08 12:35:10
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Mojo-Pg (Old)
 and      /work/SRC/openSUSE:Factory/.perl-Mojo-Pg.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-Mojo-Pg"

Sat Jul  8 12:35:10 2017 rev:5 rq:508735 version:4.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Mojo-Pg/perl-Mojo-Pg.changes        
2017-06-09 15:58:29.494487842 +0200
+++ /work/SRC/openSUSE:Factory/.perl-Mojo-Pg.new/perl-Mojo-Pg.changes   
2017-07-08 12:35:50.462253730 +0200
@@ -1,0 +2,12 @@
+Fri Jul  7 05:52:49 UTC 2017 - co...@suse.com
+
+- updated to 4.0
+   see /usr/share/doc/packages/perl-Mojo-Pg/Changes
+
+  4.0  2017-07-06
+    - Added support for sharing the database connection cache between multiple
+      Mojo::Pg objects.
+    - Added parent attribute to Mojo::Pg.
+    - Fixed a bug where automatic migrations would leak database connections.
+
+-------------------------------------------------------------------

Old:
----
  Mojo-Pg-3.06.tar.gz

New:
----
  Mojo-Pg-4.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-Mojo-Pg.spec ++++++
--- /var/tmp/diff_new_pack.jvpVYk/_old  2017-07-08 12:35:50.906191112 +0200
+++ /var/tmp/diff_new_pack.jvpVYk/_new  2017-07-08 12:35:50.906191112 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           perl-Mojo-Pg
-Version:        3.06
+Version:        4.0
 Release:        0
 %define cpan_name Mojo-Pg
 Summary:        Mojolicious ♥ PostgreSQL
@@ -41,7 +41,12 @@
 %description
 Mojo::Pg is a tiny wrapper around DBD::Pg that makes at
 http://www.postgresql.org a lot of fun to use with the at
-http://mojolicious.org real-time web framework.
+http://mojolicious.org real-time web framework. Perform queries blocking
+and non-blocking, use all at
+https://www.postgresql.org/docs/current/static/sql.html PostgreSQL has to
+offer, generate CRUD queries from data structures, manage your database
+schema with migrations and build scalable real-time web applications with
+the publish/subscribe pattern.
 
 Database and statement handles are cached automatically, and will be reused
 transparently to increase performance. You can handle connection timeouts

++++++ Mojo-Pg-3.06.tar.gz -> Mojo-Pg-4.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.06/Changes new/Mojo-Pg-4.0/Changes
--- old/Mojo-Pg-3.06/Changes    2017-06-01 17:40:12.000000000 +0200
+++ new/Mojo-Pg-4.0/Changes     2017-07-06 23:41:13.000000000 +0200
@@ -1,4 +1,10 @@
 
+4.0  2017-07-06
+  - Added support for sharing the database connection cache between multiple
+    Mojo::Pg objects.
+  - Added parent attribute to Mojo::Pg.
+  - Fixed a bug where automatic migrations would leak database connections.
+
 3.06  2017-06-01
   - Updated example application with tests.
   - Improved Mojo::Pg to be a little less noisy by deactivating PrintWarn by
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.06/META.json new/Mojo-Pg-4.0/META.json
--- old/Mojo-Pg-3.06/META.json  2017-06-01 19:49:18.000000000 +0200
+++ new/Mojo-Pg-4.0/META.json   2017-07-06 23:45:43.000000000 +0200
@@ -4,7 +4,7 @@
       "Sebastian Riedel <s...@cpan.org>"
    ],
    "dynamic_config" : 0,
-   "generated_by" : "ExtUtils::MakeMaker version 7.28, CPAN::Meta::Converter 
version 2.150010",
+   "generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter 
version 2.150010",
    "license" : [
       "artistic_2"
    ],
@@ -57,6 +57,6 @@
       },
       "x_IRC" : "irc://irc.perl.org/#mojo"
    },
-   "version" : "3.06",
+   "version" : "4.0",
    "x_serialization_backend" : "JSON::PP version 2.94"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.06/META.yml new/Mojo-Pg-4.0/META.yml
--- old/Mojo-Pg-3.06/META.yml   2017-06-01 19:49:17.000000000 +0200
+++ new/Mojo-Pg-4.0/META.yml    2017-07-06 23:45:42.000000000 +0200
@@ -7,7 +7,7 @@
 configure_requires:
   ExtUtils::MakeMaker: '0'
 dynamic_config: 0
-generated_by: 'ExtUtils::MakeMaker version 7.28, CPAN::Meta::Converter version 
2.150010'
+generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 
2.150010'
 license: artistic_2
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -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: '3.06'
+version: '4.0'
 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.06/lib/Mojo/Pg.pm 
new/Mojo-Pg-4.0/lib/Mojo/Pg.pm
--- old/Mojo-Pg-3.06/lib/Mojo/Pg.pm     2017-06-01 17:36:34.000000000 +0200
+++ new/Mojo-Pg-4.0/lib/Mojo/Pg.pm      2017-07-06 23:36:51.000000000 +0200
@@ -7,13 +7,13 @@
 use Mojo::Pg::Migrations;
 use Mojo::Pg::PubSub;
 use Mojo::URL;
-use Scalar::Util 'weaken';
+use Scalar::Util qw(blessed weaken);
 use SQL::Abstract;
 
 has abstract => sub {
   SQL::Abstract->new(array_datatypes => 1, name_sep => '.', quote_char => '"');
 };
-has [qw(auto_migrate search_path)];
+has [qw(auto_migrate parent search_path)];
 has database_class  => 'Mojo::Pg::Database';
 has dsn             => 'dbi:Pg:';
 has max_connections => 5;
@@ -38,15 +38,18 @@
   return $pubsub;
 };
 
-our $VERSION = '3.06';
+our $VERSION = '4.0';
 
-sub db { $_[0]->database_class->new(dbh => $_[0]->_dequeue, pg => $_[0]) }
+sub db { $_[0]->database_class->new(dbh => $_[0]->_prepare, pg => $_[0]) }
 
 sub from_string {
   my ($self, $str) = @_;
 
-  # Protocol
+  # Parent
   return $self unless $str;
+  return $self->parent($str) if blessed $str && $str->isa('Mojo::Pg');
+
+  # Protocol
   my $url = Mojo::URL->new($str);
   croak qq{Invalid PostgreSQL connection string "$str"}
     unless $url->protocol =~ /^postgres(?:ql)?$/;
@@ -89,9 +92,6 @@
     $dbh->do("set search_path to $search_path");
   }
 
-  # Automatic migrations
-  ++$self->{migrated} and $self->migrations->migrate
-    if !$self->{migrated} && $self->auto_migrate;
   $self->emit(connection => $dbh);
 
   return $dbh;
@@ -99,11 +99,25 @@
 
 sub _enqueue {
   my ($self, $dbh) = @_;
+
+  if (my $parent = $self->parent) { return $parent->_enqueue($dbh) }
+
   my $queue = $self->{queue} ||= [];
   push @$queue, $dbh if $dbh->{Active};
   shift @$queue while @$queue > $self->max_connections;
 }
 
+sub _prepare {
+  my $self = shift;
+
+  # Automatic migrations
+  ++$self->{migrated} and $self->migrations->migrate
+    if !$self->{migrated} && $self->auto_migrate;
+
+  my $parent = $self->parent;
+  return $parent ? $parent->_prepare : $self->_dequeue;
+}
+
 1;
 
 =encoding utf8
@@ -201,7 +215,12 @@
 
 L<Mojo::Pg> is a tiny wrapper around L<DBD::Pg> that makes
 L<PostgreSQL|http://www.postgresql.org> a lot of fun to use with the
-L<Mojolicious|http://mojolicious.org> real-time web framework.
+L<Mojolicious|http://mojolicious.org> real-time web framework. Perform queries
+blocking and non-blocking, use all
+L<SQL features|https://www.postgresql.org/docs/current/static/sql.html>
+PostgreSQL has to offer, generate CRUD queries from data structures, manage 
your
+database schema with migrations and build scalable real-time web applications
+with the publish/subscribe pattern.
 
 Database and statement handles are cached automatically, and will be reused
 transparently to increase performance. You can handle connection timeouts
@@ -326,7 +345,7 @@
   $pg      = $pg->auto_migrate($bool);
 
 Automatically migrate to the latest database schema with L</"migrations">, as
-soon as the first database connection has been established.
+soon as L</"db"> has been called for the first time.
 
 =head2 database_class
 
@@ -372,6 +391,14 @@
 as well as C<PrintWarn>. Note that C<AutoCommit> and C<RaiseError> are
 considered mandatory, so deactivating them would be very dangerous.
 
+=head2 parent
+
+  my $parent = $pg->parent;
+  $pg        = $pg->parent(Mojo::Pg->new);
+
+Another L<Mojo::Pg> object to use for connection management, instead of
+establishing and caching our own database connections.
+
 =head2 password
 
   my $password = $pg->password;
@@ -439,8 +466,10 @@
 =head2 from_string
 
   $pg = $pg->from_string('postgresql://postgres@/test');
+  $pg = $pg->from_string(Mojo::Pg->new);
 
-Parse configuration from connection string.
+Parse configuration from connection string or use another L<Mojo::Pg> object as
+L</"parent">.
 
   # Just a database
   $pg->from_string('postgresql:///db1');
@@ -470,6 +499,7 @@
 
   my $pg = Mojo::Pg->new;
   my $pg = Mojo::Pg->new('postgresql://postgres@/test');
+  my $pg = Mojo::Pg->new(Mojo::Pg->new);
 
 Construct a new L<Mojo::Pg> object and parse connection string with
 L</"from_string"> if necessary.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.06/t/database.t 
new/Mojo-Pg-4.0/t/database.t
--- old/Mojo-Pg-3.06/t/database.t       2017-04-19 17:22:13.000000000 +0200
+++ new/Mojo-Pg-4.0/t/database.t        2017-07-06 19:58:59.000000000 +0200
@@ -174,6 +174,24 @@
 };
 $pg->unsubscribe('connection');
 
+# Shared connection cache
+my $pg2 = Mojo::Pg->new($pg);
+is $pg2->parent, $pg, 'right parent';
+$dbh = $pg->db->dbh;
+is $pg->db->dbh,  $dbh, 'same database handle';
+is $pg2->db->dbh, $dbh, 'same database handle';
+is $pg->db->dbh,  $dbh, 'same database handle';
+is $pg2->db->dbh, $dbh, 'same database handle';
+$db = $pg->db;
+is_deeply $db->query('select 1 as one')->hashes->to_array, [{one => 1}],
+  'right structure';
+$dbh = $db->dbh;
+$db->disconnect;
+$db = $pg2->db;
+is_deeply $db->query('select 1 as one')->hashes->to_array, [{one => 1}],
+  'right structure';
+isnt $db->dbh, $dbh, 'different database handle';
+
 # Notifications
 $db = $pg->db;
 ok !$db->is_listening, 'not listening';
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.06/t/migrations.t 
new/Mojo-Pg-4.0/t/migrations.t
--- old/Mojo-Pg-3.06/t/migrations.t     2017-01-01 16:53:35.000000000 +0100
+++ new/Mojo-Pg-4.0/t/migrations.t      2017-07-06 23:36:56.000000000 +0200
@@ -95,7 +95,7 @@
 eval { $pg2->migrations->migrate };
 like $@, qr/does_not_exist/, 'right error';
 is $pg2->migrations->migrate(3)->active, 3, 'active version is 3';
-is $pg2->migrations->migrate(2)->active, 2, 'active version is 3';
+is $pg2->migrations->migrate(2)->active, 2, 'active version is 2';
 is $pg->migrations->active, 0, 'active version is still 0';
 is $pg->migrations->migrate->active, 10, 'active version is 10';
 is_deeply $pg2->db->query('select * from migration_test_three')
@@ -126,6 +126,17 @@
   'right structure';
 is $pg3->migrations->migrate(0)->active, 0, 'active version is 0';
 
+# Migrate automatically with shared connection cache
+my $pg4
+  = Mojo::Pg->new($ENV{TEST_ONLINE})->search_path(['mojo_migrations_test']);
+my $pg5 = Mojo::Pg->new($pg4);
+$pg4->auto_migrate(1)->migrations->name('test1')->from_data;
+$pg5->auto_migrate(1)->migrations->name('test3')->from_data;
+is_deeply $pg5->db->query('select * from migration_test_four')
+  ->hashes->to_array, [{test => 10}], 'right structure';
+is_deeply $pg5->db->query('select * from 
migration_test_six')->hashes->to_array,
+  [], 'right structure';
+
 # Unknown version
 eval { $pg->migrations->migrate(23) };
 like $@, qr/Version 23 has no migration/, 'right error';
@@ -168,3 +179,7 @@
 @@ test2
 -- 2 up
 create table migration_test_five (test int);
+
+@@ test3
+-- 2 up
+create table migration_test_six (test int);


Reply via email to