Hello community,
here is the log from the commit of package perl-Mojo-Pg for openSUSE:Factory checked in at 2017-12-20 10:40:27
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Mojo-Pg (Old)
and /work/SRC/openSUSE:Factory/.perl-Mojo-Pg.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Mojo-Pg"
Wed Dec 20 10:40:27 2017 rev:9 rq:558583 version:4.04
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Mojo-Pg/perl-Mojo-Pg.changes 2017-11-11 14:19:40.523047597 +0100
+++ /work/SRC/openSUSE:Factory/.perl-Mojo-Pg.new/perl-Mojo-Pg.changes 2017-12-20 10:40:31.836092811 +0100
@@ -1,0 +2,11 @@
+Mon Dec 18 06:36:50 UTC 2017 - coolo@suse.com
+
+- updated to 4.04
+ see /usr/share/doc/packages/perl-Mojo-Pg/Changes
+
+ 4.04 2017-12-16
+ - Added db attribute to Mojo::Pg::Results.
+ - Added sql_for method to Mojo::Pg::Migrations.
+ - Fixed a bug that could cause connections to be cached for reuse too early.
+
+-------------------------------------------------------------------
Old:
----
Mojo-Pg-4.03.tar.gz
New:
----
Mojo-Pg-4.04.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Mojo-Pg.spec ++++++
--- /var/tmp/diff_new_pack.kIxgj7/_old 2017-12-20 10:40:32.556040684 +0100
+++ /var/tmp/diff_new_pack.kIxgj7/_new 2017-12-20 10:40:32.560040394 +0100
@@ -17,7 +17,7 @@
Name: perl-Mojo-Pg
-Version: 4.03
+Version: 4.04
Release: 0
%define cpan_name Mojo-Pg
Summary: Mojolicious ♥ PostgreSQL
@@ -48,48 +48,6 @@
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
-gracefully by holding on to them only for short amounts of time.
-
- use Mojolicious::Lite;
- use Mojo::Pg;
-
- helper pg => sub { state $pg = Mojo::Pg->new('postgresql://postgres@/test') };
-
- get '/' => sub {
- my $c = shift;
- my $db = $c->pg->db;
- $c->render(json => $db->query('select now() as now')->hash);
- };
-
- app->start;
-
-In this example application, we create a 'pg' helper to store a Mojo::Pg
-object. Our action calls that helper and uses the method Mojo::Pg/"db" to
-dequeue a Mojo::Pg::Database object from the connection pool. Then we use
-the method Mojo::Pg::Database/"query" to execute an at
-http://www.postgresql.org/docs/current/static/sql.html statement, which
-returns a Mojo::Pg::Results object. And finally we call the method
-Mojo::Pg::Results/"hash" to retrieve the first row as a hash reference.
-
-While all I/O operations are performed blocking, you can wait for long
-running queries asynchronously, allowing the Mojo::IOLoop event loop to
-perform other tasks in the meantime. Since database connections usually
-have a very low latency, this often results in very good performance.
-
-Every database connection can only handle one active query at a time, this
-includes asynchronous ones. To perform multiple queries concurrently, you
-have to use multiple connections.
-
- # Performed concurrently (5 seconds)
- $pg->db->query('select pg_sleep(5)' => sub {...});
- $pg->db->query('select pg_sleep(5)' => sub {...});
-
-All cached database handles will be reset automatically if a new process
-has been forked, this allows multiple processes to share the same Mojo::Pg
-object safely.
-
%prep
%setup -q -n %{cpan_name}-%{version}
find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644
++++++ Mojo-Pg-4.03.tar.gz -> Mojo-Pg-4.04.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.03/Changes new/Mojo-Pg-4.04/Changes
--- old/Mojo-Pg-4.03/Changes 2017-11-04 18:01:39.000000000 +0100
+++ new/Mojo-Pg-4.04/Changes 2017-12-16 16:24:58.000000000 +0100
@@ -1,4 +1,9 @@
+4.04 2017-12-16
+ - Added db attribute to Mojo::Pg::Results.
+ - Added sql_for method to Mojo::Pg::Migrations.
+ - Fixed a bug that could cause connections to be cached for reuse too early.
+
4.03 2017-11-04
- Improved Mojo::Pg::Database to use Mojo::Promise.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.03/META.json new/Mojo-Pg-4.04/META.json
--- old/Mojo-Pg-4.03/META.json 2017-11-04 18:04:41.000000000 +0100
+++ new/Mojo-Pg-4.04/META.json 2017-12-17 19:00:55.000000000 +0100
@@ -57,6 +57,6 @@
},
"x_IRC" : "irc://irc.perl.org/#mojo"
},
- "version" : "4.03",
- "x_serialization_backend" : "JSON::PP version 2.94"
+ "version" : "4.04",
+ "x_serialization_backend" : "JSON::PP version 2.97000"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.03/META.yml new/Mojo-Pg-4.04/META.yml
--- old/Mojo-Pg-4.03/META.yml 2017-11-04 18:04:41.000000000 +0100
+++ new/Mojo-Pg-4.04/META.yml 2017-12-17 19:00:55.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: '4.03'
+version: '4.04'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.03/lib/Mojo/Pg/Database.pm new/Mojo-Pg-4.04/lib/Mojo/Pg/Database.pm
--- old/Mojo-Pg-4.03/lib/Mojo/Pg/Database.pm 2017-11-04 16:21:36.000000000 +0100
+++ new/Mojo-Pg-4.04/lib/Mojo/Pg/Database.pm 2017-12-16 16:23:31.000000000 +0100
@@ -106,7 +106,7 @@
# Blocking
unless ($cb) {
$self->_notifications;
- return $self->results_class->new(sth => $sth);
+ return $self->results_class->new(db => $self, sth => $sth);
}
# Non-blocking
@@ -172,7 +172,7 @@
my $result = do { local $dbh->{RaiseError} = 0; $dbh->pg_result };
my $err = defined $result ? undef : $dbh->errstr;
- $self->$cb($err, $self->results_class->new(sth => $sth));
+ $self->$cb($err, $self->results_class->new(db => $self, sth => $sth));
$self->_unwatch unless $self->{waiting} || $self->is_listening;
}
)->watch($self->{handle}, 1, 0);
@@ -308,7 +308,7 @@
my $promise = $db->delete_p($table, \%where, \%options);
Same as L"delete">, but performs all operations non-blocking and returns a
-LMojo::Promise object to be used as a promise instead of accepting a callback.
+LMojo::Promise object instead of accepting a callback.
$db->delete_p('some_table')->then(sub {
my $results = shift;
@@ -369,7 +369,7 @@
my $promise = $db->insert_p($table, \@values || \%fieldvals, \%options);
Same as L"insert">, but performs all operations non-blocking and returns a
-LMojo::Promise object to be used as a promise instead of accepting a callback.
+LMojo::Promise object instead of accepting a callback.
$db->insert_p(some_table => {foo => 'bar'})->then(sub {
my $results = shift;
@@ -451,7 +451,7 @@
my $promise = $db->query_p('select * from foo');
Same as L"query">, but performs all operations non-blocking and returns a
-LMojo::Promise object to be used as a promise instead of accepting a callback.
+LMojo::Promise object instead of accepting a callback.
$db->query_p('insert into foo values (?, ?, ?)' => @values)->then(sub {
my $results = shift;
@@ -498,7 +498,7 @@
my $promise = $db->select_p($source, $fields, $where, $order);
Same as L"select">, but performs all operations non-blocking and returns a
-LMojo::Promise object to be used as a promise instead of accepting a callback.
+LMojo::Promise object instead of accepting a callback.
$db->select_p(some_table => ['foo'] => {bar => 'yada'})->then(sub {
my $results = shift;
@@ -559,7 +559,7 @@
my $promise = $db->update_p($table, \%fieldvals, \%where, \%options);
Same as L"update">, but performs all operations non-blocking and returns a
-LMojo::Promise object to be used as a promise instead of accepting a
+LMojo::Promise object instead of accepting a
callback.
$db->update_p(some_table => {foo => 'baz'} => {foo => 'bar'})->then(sub {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.03/lib/Mojo/Pg/Migrations.pm new/Mojo-Pg-4.04/lib/Mojo/Pg/Migrations.pm
--- old/Mojo-Pg-4.03/lib/Mojo/Pg/Migrations.pm 2017-06-24 15:01:30.000000000 +0200
+++ new/Mojo-Pg-4.04/lib/Mojo/Pg/Migrations.pm 2017-12-14 19:43:41.000000000 +0100
@@ -60,19 +60,7 @@
croak "Active version $active is greater than the latest version $latest"
if $active > $latest;
- # Up
- my $sql;
- if ($active < $target) {
- my @up = grep { $_ <= $target && $_ > $active } keys %$up;
- $sql = join '', @$up{sort { $a <=> $b } @up};
- }
-
- # Down
- else {
- my @down = grep { $_ > $target && $_ <= $active } keys %$down;
- $sql = join '', @$down{reverse sort { $a <=> $b } @down};
- }
-
+ my $sql = $self->sql_for($active, $target);
warn "-- Migrate ($active -> $target)\n$sql\n" if DEBUG;
$sql .= ';update mojo_migrations set version = $1 where name = $2;';
$db->query($sql, $target, $self->name) and $tx->commit;
@@ -80,6 +68,21 @@
return $self;
}
+sub sql_for {
+ my ($self, $from, $to) = @_;
+
+ # Up
+ my ($up, $down) = @{$self->{migrations}}{qw(up down)};
+ if ($from < $to) {
+ my @up = grep { $_ <= $to && $_ > $from } keys %$up;
+ return join '', @$up{sort { $a <=> $b } @up};
+ }
+
+ # Down
+ my @down = grep { $_ > $to && $_ <= $from } keys %$down;
+ return join '', @$down{reverse sort { $a <=> $b } @down};
+}
+
sub _active {
my ($self, $db, $create) = @_;
@@ -225,6 +228,12 @@
# Reset database
$migrations->migrate(0)->migrate;
+=head2 sql_for
+
+ my $sql = $migrations->sql_for(5, 10);
+
+Get SQL to migrate from one version to another, up or down.
+
=head1 DEBUGGING
You can set the C