Hello community,

here is the log from the commit of package perl-Mojo-Pg for openSUSE:Factory 
checked in at 2020-11-09 13:58:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Mojo-Pg (Old)
 and      /work/SRC/openSUSE:Factory/.perl-Mojo-Pg.new.11331 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-Mojo-Pg"

Mon Nov  9 13:58:40 2020 rev:25 rq:847120 version:4.22

Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Mojo-Pg/perl-Mojo-Pg.changes        
2020-10-27 19:01:52.710871305 +0100
+++ /work/SRC/openSUSE:Factory/.perl-Mojo-Pg.new.11331/perl-Mojo-Pg.changes     
2020-11-09 13:59:20.847710760 +0100
@@ -1,0 +2,10 @@
+Sat Nov  7 03:17:51 UTC 2020 - Tina Müller <[email protected]>
+
+- updated to 4.22
+   see /usr/share/doc/packages/perl-Mojo-Pg/Changes
+
+  4.22  2020-11-06
+    - Added from_dir method to Mojo::Pg::Migrations. (kiwiroy)
+    - Improved Mojo::Pg::Database to handle connection errors more gracefully.
+
+-------------------------------------------------------------------

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

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

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

Other differences:
------------------
++++++ perl-Mojo-Pg.spec ++++++
--- /var/tmp/diff_new_pack.X5iwai/_old  2020-11-09 13:59:21.631709051 +0100
+++ /var/tmp/diff_new_pack.X5iwai/_new  2020-11-09 13:59:21.635709042 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           perl-Mojo-Pg
-Version:        4.21
+Version:        4.22
 Release:        0
 %define cpan_name Mojo-Pg
 Summary:        Wrapper around DBD::Pg for using PostgreSql with Mojolicious

++++++ Mojo-Pg-4.21.tar.gz -> Mojo-Pg-4.22.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/Changes new/Mojo-Pg-4.22/Changes
--- old/Mojo-Pg-4.21/Changes    2020-10-25 18:08:42.000000000 +0100
+++ new/Mojo-Pg-4.22/Changes    2020-11-06 20:44:58.000000000 +0100
@@ -1,4 +1,8 @@
 
+4.22  2020-11-06
+  - Added from_dir method to Mojo::Pg::Migrations. (kiwiroy)
+  - Improved Mojo::Pg::Database to handle connection errors more gracefully.
+
 4.21  2020-10-25
   - Added reset method to Mojo::Pg.
   - Changed SQL style to use uppercase keywords.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/MANIFEST new/Mojo-Pg-4.22/MANIFEST
--- old/Mojo-Pg-4.21/MANIFEST   2020-10-26 00:09:25.000000000 +0100
+++ new/Mojo-Pg-4.22/MANIFEST   2020-11-06 20:46:42.000000000 +0100
@@ -31,6 +31,15 @@
 t/database.t
 t/migrations.t
 t/migrations/test.sql
+t/migrations/tree/1/down.sql
+t/migrations/tree/1/up.sql
+t/migrations/tree/2/down.sql
+t/migrations/tree/2/up.sql
+t/migrations/tree/36/up.sql
+t/migrations/tree/55/upgrade.sql
+t/migrations/tree/99/up.sql
+t/migrations/tree2/8/up.sql
+t/migrations/tree2/subtree/9/up.sql
 t/pg_lite_app.t
 t/pod.t
 t/pod_coverage.t
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/META.json new/Mojo-Pg-4.22/META.json
--- old/Mojo-Pg-4.21/META.json  2020-10-26 00:09:25.000000000 +0100
+++ new/Mojo-Pg-4.22/META.json  2020-11-06 20:46:42.000000000 +0100
@@ -60,6 +60,6 @@
          "web" : "https://webchat.freenode.net/#mojo";
       }
    },
-   "version" : "4.21",
+   "version" : "4.22",
    "x_serialization_backend" : "JSON::PP version 4.05"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/META.yml new/Mojo-Pg-4.22/META.yml
--- old/Mojo-Pg-4.21/META.yml   2020-10-26 00:09:25.000000000 +0100
+++ new/Mojo-Pg-4.22/META.yml   2020-11-06 20:46:42.000000000 +0100
@@ -32,5 +32,5 @@
   homepage: https://mojolicious.org
   license: http://www.opensource.org/licenses/artistic-license-2.0
   repository: https://github.com/mojolicious/mojo-pg.git
-version: '4.21'
+version: '4.22'
 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/lib/Mojo/Pg/Database.pm 
new/Mojo-Pg-4.22/lib/Mojo/Pg/Database.pm
--- old/Mojo-Pg-4.21/lib/Mojo/Pg/Database.pm    2020-10-24 23:47:39.000000000 
+0200
+++ new/Mojo-Pg-4.22/lib/Mojo/Pg/Database.pm    2020-11-06 20:43:14.000000000 
+0100
@@ -137,10 +137,10 @@
 
   my $dbh = $self->dbh;
   my $n;
-  return undef unless $n = $dbh->pg_notifies;
+  return undef unless $n = eval { $dbh->pg_notifies };
   while ($n) {
     $self->emit(notification => @$n);
-    $n = $dbh->pg_notifies;
+    $n = eval { $dbh->pg_notifies };
   }
 
   return 1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/lib/Mojo/Pg/Migrations.pm 
new/Mojo-Pg-4.22/lib/Mojo/Pg/Migrations.pm
--- old/Mojo-Pg-4.21/lib/Mojo/Pg/Migrations.pm  2020-10-24 23:31:09.000000000 
+0200
+++ new/Mojo-Pg-4.22/lib/Mojo/Pg/Migrations.pm  2020-11-06 20:09:42.000000000 
+0100
@@ -18,6 +18,19 @@
   return $self->from_string(data_section($class //= caller, $name // 
$self->name));
 }
 
+sub from_dir {
+  my ($self, $dir) = @_;
+
+  my $migrations = $self->{migrations} = {up => {}, down => {}};
+  for my $file (path($dir)->list_tree({max_depth => 2})->each) {
+    next unless my ($way)     = ($file->basename          =~ 
/^(up|down)\.sql$/);
+    next unless my ($version) = ($file->dirname->basename =~ /^(\d+)$/);
+    $migrations->{$way}{$version} = decode 'UTF-8', $file->slurp;
+  }
+
+  return $self;
+}
+
 sub from_file { shift->from_string(decode 'UTF-8', path(pop)->slurp) }
 
 sub from_string {
@@ -186,6 +199,19 @@
   -- 1 down
   DROP TABLE messages;
 
+=head2 from_dir
+
+  $migrations = $migrations->from_dir('/home/sri/migrations');
+
+Extract migrations from a directory tree where each versioned migration is in 
a directory, named for the version, and
+each migration has one or both of the files named C<up.sql> or C<down.sql>.
+
+  migrations/1/up.sql
+  migrations/1/down.sql
+  migrations/2/up.sql
+  migrations/3/up.sql
+  migrations/3/down.sql
+
 =head2 from_file
 
   $migrations = $migrations->from_file('/home/sri/migrations.sql');
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/lib/Mojo/Pg.pm 
new/Mojo-Pg-4.22/lib/Mojo/Pg.pm
--- old/Mojo-Pg-4.21/lib/Mojo/Pg.pm     2020-10-25 18:07:28.000000000 +0100
+++ new/Mojo-Pg-4.22/lib/Mojo/Pg.pm     2020-10-26 00:10:04.000000000 +0100
@@ -22,7 +22,7 @@
 has [qw(password username)] => '';
 has pubsub                  => sub { Mojo::Pg::PubSub->new(pg => shift) };
 
-our $VERSION = '4.21';
+our $VERSION = '4.22';
 
 sub db { $_[0]->database_class->new(dbh => $_[0]->_prepare, pg => $_[0]) }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/t/database.t 
new/Mojo-Pg-4.22/t/database.t
--- old/Mojo-Pg-4.21/t/database.t       2020-10-25 18:08:15.000000000 +0100
+++ new/Mojo-Pg-4.22/t/database.t       2020-10-26 13:39:08.000000000 +0100
@@ -226,7 +226,7 @@
   isnt $db->dbh, $dbh, 'different database handle';
 };
 
-subtest 'Cahce reset' => sub {
+subtest 'Cache reset' => sub {
   my $dbh = $pg->db->dbh;
   is $pg->db->dbh, $dbh, 'same database handle';
   is $pg->db->dbh, $dbh, 'same database handle again';
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/t/migrations/tree/1/down.sql 
new/Mojo-Pg-4.22/t/migrations/tree/1/down.sql
--- old/Mojo-Pg-4.21/t/migrations/tree/1/down.sql       1970-01-01 
01:00:00.000000000 +0100
+++ new/Mojo-Pg-4.22/t/migrations/tree/1/down.sql       2020-10-28 
23:51:43.000000000 +0100
@@ -0,0 +1 @@
+DROP TABLE IF EXISTS migration_test_three;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/t/migrations/tree/1/up.sql 
new/Mojo-Pg-4.22/t/migrations/tree/1/up.sql
--- old/Mojo-Pg-4.21/t/migrations/tree/1/up.sql 1970-01-01 01:00:00.000000000 
+0100
+++ new/Mojo-Pg-4.22/t/migrations/tree/1/up.sql 2020-10-28 23:51:43.000000000 
+0100
@@ -0,0 +1 @@
+CREATE TABLE IF NOT EXISTS migration_test_three (baz VARCHAR(255));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/t/migrations/tree/2/up.sql 
new/Mojo-Pg-4.22/t/migrations/tree/2/up.sql
--- old/Mojo-Pg-4.21/t/migrations/tree/2/up.sql 1970-01-01 01:00:00.000000000 
+0100
+++ new/Mojo-Pg-4.22/t/migrations/tree/2/up.sql 2020-10-28 23:51:43.000000000 
+0100
@@ -0,0 +1,2 @@
+INSERT INTO migration_test_three VALUES ('just');
+INSERT INTO migration_test_three VALUES ('works ♥');
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/t/migrations/tree/55/upgrade.sql 
new/Mojo-Pg-4.22/t/migrations/tree/55/upgrade.sql
--- old/Mojo-Pg-4.21/t/migrations/tree/55/upgrade.sql   1970-01-01 
01:00:00.000000000 +0100
+++ new/Mojo-Pg-4.22/t/migrations/tree/55/upgrade.sql   2020-10-28 
23:51:43.000000000 +0100
@@ -0,0 +1 @@
+CREATE TABLE IF NOT EXISTS mojo_migrations_upgrading (baz VARCHAR(255));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/t/migrations/tree/99/up.sql 
new/Mojo-Pg-4.22/t/migrations/tree/99/up.sql
--- old/Mojo-Pg-4.21/t/migrations/tree/99/up.sql        1970-01-01 
01:00:00.000000000 +0100
+++ new/Mojo-Pg-4.22/t/migrations/tree/99/up.sql        2020-10-28 
23:51:43.000000000 +0100
@@ -0,0 +1 @@
+CREATE TABLE IF NOT EXISTS migration_test_luft_balloons (baz VARCHAR(255));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/t/migrations/tree2/8/up.sql 
new/Mojo-Pg-4.22/t/migrations/tree2/8/up.sql
--- old/Mojo-Pg-4.21/t/migrations/tree2/8/up.sql        1970-01-01 
01:00:00.000000000 +0100
+++ new/Mojo-Pg-4.22/t/migrations/tree2/8/up.sql        2020-10-28 
23:51:43.000000000 +0100
@@ -0,0 +1 @@
+CREATE TABLE IF NOT EXISTS mojo_migrations_test8 (foo VARCHAR(255));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/t/migrations/tree2/subtree/9/up.sql 
new/Mojo-Pg-4.22/t/migrations/tree2/subtree/9/up.sql
--- old/Mojo-Pg-4.21/t/migrations/tree2/subtree/9/up.sql        1970-01-01 
01:00:00.000000000 +0100
+++ new/Mojo-Pg-4.22/t/migrations/tree2/subtree/9/up.sql        2020-10-28 
23:51:43.000000000 +0100
@@ -0,0 +1 @@
+CREATE TABLE IF NOT EXISTS mojo_migrations_test9 (foo VARCHAR(255));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Mojo-Pg-4.21/t/migrations.t 
new/Mojo-Pg-4.22/t/migrations.t
--- old/Mojo-Pg-4.21/t/migrations.t     2020-10-24 23:29:49.000000000 +0200
+++ new/Mojo-Pg-4.22/t/migrations.t     2020-11-06 20:06:35.000000000 +0100
@@ -6,8 +6,7 @@
 
 plan skip_all => 'set TEST_ONLINE to enable this test' unless 
$ENV{TEST_ONLINE};
 
-use File::Spec::Functions qw(catfile);
-use FindBin;
+use Mojo::File qw(curfile);
 use Mojo::Pg;
 
 # Isolate tests
@@ -81,7 +80,7 @@
 
 subtest 'Bad and concurrent migrations' => sub {
   my $pg2 = 
Mojo::Pg->new($ENV{TEST_ONLINE})->search_path(['mojo_migrations_test']);
-  $pg2->migrations->name('migrations_test2')->from_file(catfile($FindBin::Bin, 
'migrations', 'test.sql'));
+  
$pg2->migrations->name('migrations_test2')->from_file(curfile->sibling('migrations',
 'test.sql'));
   is $pg2->migrations->latest, 4, 'latest version is 4';
   is $pg2->migrations->active, 0, 'active version is 0';
   eval { $pg2->migrations->migrate };
@@ -166,6 +165,31 @@
   is $pg->migrations->from_string($newer)->migrate(0)->active, 0, 'active 
version is 0';
 };
 
+subtest 'Migration directory' => sub {
+  my $pg = 
Mojo::Pg->new($ENV{TEST_ONLINE})->search_path(['mojo_migrations_test']);
+  $pg->migrations->name('directory 
tree')->from_dir(curfile->sibling('migrations', 'tree'));
+  is $pg->migrations->migrate(0)->migrate(2)->active, 2, 'migrate table with 
unicode';
+  is_deeply $pg->db->query('SELECT * FROM migration_test_three')->hashes, 
[{baz => 'just'}, {baz => 'works ♥'}],
+    'right structure';
+
+  eval { $pg->migrations->migrate(36) };
+  like $@, qr/^Version 36 has no migration/, 'empty file has no version';
+  eval { $pg->migrations->migrate(54) };
+  like $@, qr/^Version 54 has no migration/, 'sparse directory has no version';
+  eval { $pg->migrations->migrate(55) };
+  like $@, qr/^Version 55 has no migration/, 'upgrade.sql is not up.sql, so no 
version';
+
+  is $pg->migrations->migrate->active, 99, 'active version is 99';
+  is $pg->migrations->latest, 99, 'latest version is 99';
+  ok !!(grep {/^mojo_migrations_test\.migration_test_luft_balloons$/} 
@{$pg->db->tables}), 'last table exists';
+
+  $pg->migrations->name('directory 
tree')->from_dir(curfile->sibling('migrations', 'tree2'));
+  is $pg->migrations->latest, 8, 'latest version is 8';
+
+  is $pg->migrations->name('directory 
tree')->from_dir(curfile->sibling('migrations', 'tree3'))->latest, 0,
+    'latest version is 0';
+};
+
 # Clean up once we are done
 $pg->db->query('DROP SCHEMA mojo_migrations_test CASCADE');
 


Reply via email to