Hello community,

here is the log from the commit of package perl-Mojo-Pg for openSUSE:Factory 
checked in at 2017-03-16 09:42:54
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Mojo-Pg (Old)
 and      /work/SRC/openSUSE:Factory/.perl-Mojo-Pg.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-Mojo-Pg"

Thu Mar 16 09:42:54 2017 rev:2 rq:479451 version:3.04

Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Mojo-Pg/perl-Mojo-Pg.changes        
2017-03-12 20:01:18.916550360 +0100
+++ /work/SRC/openSUSE:Factory/.perl-Mojo-Pg.new/perl-Mojo-Pg.changes   
2017-03-16 09:51:47.159659430 +0100
@@ -1,0 +2,18 @@
+Thu Mar  9 07:03:38 UTC 2017 - co...@suse.com
+
+- updated to 3.04
+   see /usr/share/doc/packages/perl-Mojo-Pg/Changes
+
+  3.04  2017-03-08
+    - Fixed array reference handling in queries generated with SQL::Abstract.
+
+-------------------------------------------------------------------
+Wed Mar  8 07:07:56 UTC 2017 - co...@suse.com
+
+- updated to 3.03
+   see /usr/share/doc/packages/perl-Mojo-Pg/Changes
+
+  3.03  2017-03-07
+    - Added reset method to Mojo::Pg::PubSub.
+
+-------------------------------------------------------------------

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

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

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

Other differences:
------------------
++++++ perl-Mojo-Pg.spec ++++++
--- /var/tmp/diff_new_pack.cl6dan/_old  2017-03-16 09:51:47.687584666 +0100
+++ /var/tmp/diff_new_pack.cl6dan/_new  2017-03-16 09:51:47.687584666 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           perl-Mojo-Pg
-Version:        3.02
+Version:        3.04
 Release:        0
 %define cpan_name Mojo-Pg
 Summary:        Mojolicious ♥ PostgreSQL

++++++ Mojo-Pg-3.02.tar.gz -> Mojo-Pg-3.04.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.02/Changes new/Mojo-Pg-3.04/Changes
--- old/Mojo-Pg-3.02/Changes    2017-02-18 14:42:09.000000000 +0100
+++ new/Mojo-Pg-3.04/Changes    2017-03-08 09:34:08.000000000 +0100
@@ -1,4 +1,10 @@
 
+3.04  2017-03-08
+  - Fixed array reference handling in queries generated with SQL::Abstract.
+
+3.03  2017-03-07
+  - Added reset method to Mojo::Pg::PubSub.
+
 3.02  2017-02-18
   - Fixed quoting bugs in queries generated with SQL::Abstract.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.02/META.json new/Mojo-Pg-3.04/META.json
--- old/Mojo-Pg-3.02/META.json  2017-02-19 00:57:30.000000000 +0100
+++ new/Mojo-Pg-3.04/META.json  2017-03-08 09:45:40.000000000 +0100
@@ -57,6 +57,6 @@
       },
       "x_IRC" : "irc://irc.perl.org/#mojo"
    },
-   "version" : "3.02",
+   "version" : "3.04",
    "x_serialization_backend" : "JSON::PP version 2.27400"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.02/META.yml new/Mojo-Pg-3.04/META.yml
--- old/Mojo-Pg-3.02/META.yml   2017-02-19 00:57:29.000000000 +0100
+++ new/Mojo-Pg-3.04/META.yml   2017-03-08 09:45:40.000000000 +0100
@@ -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.02'
+version: '3.04'
 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.02/lib/Mojo/Pg/Database.pm 
new/Mojo-Pg-3.04/lib/Mojo/Pg/Database.pm
--- old/Mojo-Pg-3.02/lib/Mojo/Pg/Database.pm    2017-02-12 16:45:52.000000000 
+0100
+++ new/Mojo-Pg-3.04/lib/Mojo/Pg/Database.pm    2017-03-08 09:43:34.000000000 
+0100
@@ -27,7 +27,7 @@
   $waiting->{cb}($self, 'Premature connection close', undef) if $waiting->{cb};
 
   return unless (my $pg = $self->pg) && (my $dbh = $self->dbh);
-  $pg->_enqueue($dbh);
+  $pg->_enqueue($dbh) unless $dbh->{private_mojo_no_reuse};
 }
 
 sub begin {
@@ -324,6 +324,9 @@
   # "insert into some_table (foo, baz) values ('bar', 'yada')"
   $db->insert('some_table', {foo => 'bar', baz => 'yada'});
 
+  # "insert into some_table (foo) values ({1,2,3})"
+  $db->insert('some_table', {foo => [1, 2, 3]});
+
   # "insert into some_table (foo) values ('bar') returning id"
   $db->insert('some_table', {foo => 'bar'}, {returning => 'id'});
 
@@ -466,6 +469,9 @@
   # "update some_table set foo = 'bar' where id = 23"
   $db->update('some_table', {foo => 'bar'}, {id => 23});
 
+  # "update some_table set foo = {1,2,3} where id = 23"
+  $db->update('some_table', {foo => [1, 2, 3]}, {id => 23});
+
   # "update some_table set foo = 'bar' where foo like '%test%'"
   $db->update('some_table', {foo => 'bar'}, {foo => {-like => '%test%'}});
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.02/lib/Mojo/Pg/PubSub.pm 
new/Mojo-Pg-3.04/lib/Mojo/Pg/PubSub.pm
--- old/Mojo-Pg-3.02/lib/Mojo/Pg/PubSub.pm      2017-01-01 18:59:40.000000000 
+0100
+++ new/Mojo-Pg-3.04/lib/Mojo/Pg/PubSub.pm      2017-03-07 21:20:27.000000000 
+0100
@@ -6,7 +6,7 @@
 
 has 'pg';
 
-sub DESTROY { Mojo::Util::_global_destruction() or shift->_cleanup }
+sub DESTROY { Mojo::Util::_global_destruction() or shift->reset }
 
 sub json { ++$_[0]{json}{$_[1]} and return $_[0] }
 
@@ -19,6 +19,13 @@
 
 sub notify { $_[0]->_db->notify(_json(@_)) and return $_[0] }
 
+sub reset {
+  my $self = shift;
+  delete @$self{qw(chans json pid)};
+  return unless my $db = delete $self->{db};
+  ++$db->dbh->{private_mojo_no_reuse} and $db->_unwatch;
+}
+
 sub unlisten {
   my ($self, $name, $cb) = @_;
   my $chan = $self->{chans}{$name};
@@ -27,18 +34,9 @@
   return $self;
 }
 
-sub _cleanup {
-  my $self = shift;
-  $self->{db}->_unwatch;
-  delete @$self{qw(chans db pid)};
-}
-
 sub _db {
   my $self = shift;
 
-  # Fork-safety
-  $self->_cleanup unless ($self->{pid} //= $$) eq $$;
-
   return $self->{db} if $self->{db};
 
   my $db = $self->{db} = $self->pg->db;
@@ -51,12 +49,7 @@
       for my $cb (@{$self->{chans}{$name}}) { $self->$cb($payload) }
     }
   );
-  $db->once(
-    close => sub {
-      delete $self->{db};
-      eval { $self->_db };
-    }
-  );
+  $db->once(close => sub { $self->{pg} and $self->_db if delete $self->{db} });
   $db->listen($_) for keys %{$self->{chans}}, 'mojo.pubsub';
   $self->emit(reconnect => $db);
 
@@ -92,10 +85,6 @@
 many consumers to share the same database connection, to avoid many common
 scalability problems.
 
-All subscriptions will be reset automatically and the database connection
-re-established if a new process has been forked, this allows multiple processes
-to share the same L<Mojo::Pg::PubSub> object safely.
-
 =head1 EVENTS
 
 L<Mojo::Pg::PubSub> inherits all events from L<Mojo::EventEmitter> and can
@@ -168,6 +157,14 @@
 Notify a channel. Automatic encoding of Perl values to JSON text can be
 activated with L</"json">.
 
+=head2 reset
+
+  $pubsub->reset;
+
+Reset all subscriptions and the database connection. This is usually done after
+a new process has been forked, to prevent the child process from stealing
+notifications meant for the parent process.
+
 =head2 unlisten
 
   $pubsub = $pubsub->unlisten('foo');
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.02/lib/Mojo/Pg.pm 
new/Mojo-Pg-3.04/lib/Mojo/Pg.pm
--- old/Mojo-Pg-3.02/lib/Mojo/Pg.pm     2017-02-18 14:44:30.000000000 +0100
+++ new/Mojo-Pg-3.04/lib/Mojo/Pg.pm     2017-03-08 09:33:16.000000000 +0100
@@ -10,7 +10,9 @@
 use Scalar::Util 'weaken';
 use SQL::Abstract;
 
-has abstract => sub { SQL::Abstract->new(name_sep => '.', quote_char => '"') };
+has abstract => sub {
+  SQL::Abstract->new(array_datatypes => 1, name_sep => '.', quote_char => '"');
+};
 has [qw(auto_migrate search_path)];
 has database_class  => 'Mojo::Pg::Database';
 has dsn             => 'dbi:Pg:';
@@ -30,7 +32,7 @@
   return $pubsub;
 };
 
-our $VERSION = '3.02';
+our $VERSION = '3.04';
 
 sub db { $_[0]->database_class->new(dbh => $_[0]->_dequeue, pg => $_[0]) }
 
@@ -128,8 +130,8 @@
   # Use SQL::Abstract to generate simple CRUD queries for you
   $db->insert('names', {name => 'Isabel'});
   my $id = $db->select('names', ['id'], {name => 'Isabel'})->hash->{id};
-  $db->update('names', {name => 'Bel'}, {id => $id});
-  $db->delete('names', {name => 'Bel'});
+  $db->update('names', {name => 'Belle'}, {id => $id});
+  $db->delete('names', {name => 'Belle'});
 
   # Insert a few rows in a transaction with SQL and placeholders
   eval {
@@ -303,7 +305,8 @@
   $pg          = $pg->abstract(SQL::Abstract->new);
 
 L<SQL::Abstract> object used to generate CRUD queries for 
L<Mojo::Pg::Database>,
-defaults to setting C<name_sep> to C<.> and C<quote_char> to C<">.
+defaults to enabling C<array_datatypes> and setting C<name_sep> to C<.> and
+C<quote_char> to C<">.
 
   # Generate WHERE clause and bind values
   my($stmt, @bind) = $pg->abstract->where({foo => 'bar', baz => 'yada'});
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.02/t/crud.t new/Mojo-Pg-3.04/t/crud.t
--- old/Mojo-Pg-3.02/t/crud.t   2017-02-18 14:39:35.000000000 +0100
+++ new/Mojo-Pg-3.04/t/crud.t   2017-03-08 00:49:23.000000000 +0100
@@ -81,6 +81,20 @@
   [{id => 1, 't e s t' => 'foo'}, {id => 2, 't e s t' => 'bar'}],
   'right structure';
 
+# Arrays
+$db->query(
+  'create table if not exists crud_test3 (
+     id   serial primary key,
+     names text[]
+   )'
+);
+$db->insert('crud_test3', {names => ['foo', 'bar']});
+is_deeply $db->select('crud_test3')->hashes->to_array,
+  [{id => 1, names => ['foo', 'bar']}], 'right structure';
+$db->update('crud_test3', {names => ['foo', 'bar', 'baz', 'yada']}, {id => 1});
+is_deeply $db->select('crud_test3')->hashes->to_array,
+  [{id => 1, names => ['foo', 'bar', 'baz', 'yada']}], 'right structure';
+
 # Clean up once we are done
 $pg->db->query('drop schema mojo_crud_test cascade');
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-3.02/t/pubsub.t new/Mojo-Pg-3.04/t/pubsub.t
--- old/Mojo-Pg-3.02/t/pubsub.t 2016-08-10 14:36:49.000000000 +0200
+++ new/Mojo-Pg-3.04/t/pubsub.t 2017-03-07 20:05:43.000000000 +0100
@@ -125,7 +125,7 @@
   is_deeply \@test, ['works too'], 'right messages';
 };
 
-# Fork-safety
+# Reset
 $pg = Mojo::Pg->new($ENV{TEST_ONLINE});
 @dbhs = @test = ();
 $pg->pubsub->on(reconnect => sub { push @dbhs, pop->dbh });
@@ -134,7 +134,7 @@
 $pg->pubsub->notify(pstest => 'first');
 is_deeply \@test, ['first'], 'right messages';
 {
-  local $$ = -23;
+  $pg->pubsub->reset;
   $pg->pubsub->notify(pstest => 'second');
   ok $dbhs[1], 'database handle';
   isnt $dbhs[0], $dbhs[1], 'different database handles';


Reply via email to