Hello community, here is the log from the commit of package perl-Mojo-Pg for openSUSE:Factory checked in at 2018-08-31 10:42:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Mojo-Pg (Old) and /work/SRC/openSUSE:Factory/.perl-Mojo-Pg.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Mojo-Pg" Fri Aug 31 10:42:33 2018 rev:12 rq:631274 version:4.09 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Mojo-Pg/perl-Mojo-Pg.changes 2018-02-03 15:42:25.601583722 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Mojo-Pg.new/perl-Mojo-Pg.changes 2018-08-31 10:43:43.859151476 +0200 @@ -1,0 +2,6 @@ +Fri Aug 3 05:37:58 UTC 2018 - [email protected] + +- updated to 4.09 + see /usr/share/doc/packages/perl-Mojo-Pg/Changes + +------------------------------------------------------------------- Old: ---- Mojo-Pg-4.08.tar.gz New: ---- Mojo-Pg-4.09.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Mojo-Pg.spec ++++++ --- /var/tmp/diff_new_pack.iud2tz/_old 2018-08-31 10:43:44.271151965 +0200 +++ /var/tmp/diff_new_pack.iud2tz/_new 2018-08-31 10:43:44.271151965 +0200 @@ -17,7 +17,7 @@ Name: perl-Mojo-Pg -Version: 4.08 +Version: 4.09 Release: 0 %define cpan_name Mojo-Pg Summary: Mojolicious ♥ PostgreSQL @@ -32,16 +32,16 @@ BuildRequires: perl-macros BuildRequires: perl(DBD::Pg) >= 3.005001 BuildRequires: perl(Mojolicious) >= 7.53 -BuildRequires: perl(SQL::Abstract) >= 1.85 +BuildRequires: perl(SQL::Abstract) >= 1.86 Requires: perl(DBD::Pg) >= 3.005001 Requires: perl(Mojolicious) >= 7.53 -Requires: perl(SQL::Abstract) >= 1.85 +Requires: perl(SQL::Abstract) >= 1.86 %{perl_requires} %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. Perform queries blocking +https://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 ++++++ Mojo-Pg-4.08.tar.gz -> Mojo-Pg-4.09.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/Changes new/Mojo-Pg-4.09/Changes --- old/Mojo-Pg-4.08/Changes 2018-01-29 18:59:30.000000000 +0100 +++ new/Mojo-Pg-4.09/Changes 2018-08-02 01:02:41.000000000 +0200 @@ -1,4 +1,11 @@ +4.09 2018-08-02 + - Added support for -json unary op to SQL::Abstract::Pg. + - Added support for multi-column unique constraints in upserts to + SQL::Abstract::Pg. + - Added support for literal SQL with bind values in select fields to + SQL::Abstract::Pg. + 4.08 2018-01-29 - Improved on_conflict option of insert and insert_p methods in Mojo::Pg::Database with a shortcut for simple conflict targets. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/META.json new/Mojo-Pg-4.09/META.json --- old/Mojo-Pg-4.08/META.json 2018-01-29 19:29:36.000000000 +0100 +++ new/Mojo-Pg-4.09/META.json 2018-08-02 01:03:45.000000000 +0200 @@ -4,7 +4,7 @@ "Sebastian Riedel <[email protected]>" ], "dynamic_config" : 0, - "generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010", + "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010", "license" : [ "artistic_2" ], @@ -36,7 +36,7 @@ "requires" : { "DBD::Pg" : "3.005001", "Mojolicious" : "7.53", - "SQL::Abstract" : "1.85", + "SQL::Abstract" : "1.86", "perl" : "5.010001" } } @@ -46,7 +46,7 @@ "bugtracker" : { "web" : "https://github.com/kraih/mojo-pg/issues" }, - "homepage" : "http://mojolicious.org", + "homepage" : "https://mojolicious.org", "license" : [ "http://www.opensource.org/licenses/artistic-license-2.0" ], @@ -57,6 +57,6 @@ }, "x_IRC" : "irc://irc.perl.org/#mojo" }, - "version" : "4.08", + "version" : "4.09", "x_serialization_backend" : "JSON::PP version 2.97001" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/META.yml new/Mojo-Pg-4.09/META.yml --- old/Mojo-Pg-4.08/META.yml 2018-01-29 19:29:36.000000000 +0100 +++ new/Mojo-Pg-4.09/META.yml 2018-08-02 01:03:45.000000000 +0200 @@ -7,7 +7,7 @@ configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 -generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010' +generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010' license: artistic_2 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -22,13 +22,13 @@ requires: DBD::Pg: '3.005001' Mojolicious: '7.53' - SQL::Abstract: '1.85' + SQL::Abstract: '1.86' perl: '5.010001' resources: IRC: irc://irc.perl.org/#mojo bugtracker: https://github.com/kraih/mojo-pg/issues - homepage: http://mojolicious.org + homepage: https://mojolicious.org license: http://www.opensource.org/licenses/artistic-license-2.0 repository: https://github.com/kraih/mojo-pg.git -version: '4.08' +version: '4.09' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/Makefile.PL new/Mojo-Pg-4.09/Makefile.PL --- old/Mojo-Pg-4.08/Makefile.PL 2018-01-27 13:36:58.000000000 +0100 +++ new/Mojo-Pg-4.09/Makefile.PL 2018-08-02 00:32:41.000000000 +0200 @@ -19,7 +19,7 @@ prereqs => {runtime => {requires => {perl => '5.010001'}}}, resources => { bugtracker => {web => 'https://github.com/kraih/mojo-pg/issues'}, - homepage => 'http://mojolicious.org', + homepage => 'https://mojolicious.org', license => ['http://www.opensource.org/licenses/artistic-license-2.0'], repository => { type => 'git', @@ -30,6 +30,6 @@ }, }, PREREQ_PM => - {'DBD::Pg' => 3.005001, Mojolicious => '7.53', 'SQL::Abstract' => '1.85'}, + {'DBD::Pg' => 3.005001, Mojolicious => '7.53', 'SQL::Abstract' => '1.86'}, test => {TESTS => 't/*.t t/*/*.t'} ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/README.md new/Mojo-Pg-4.09/README.md --- old/Mojo-Pg-4.08/README.md 2017-11-02 20:12:50.000000000 +0100 +++ new/Mojo-Pg-4.09/README.md 2018-05-10 17:18:14.000000000 +0200 @@ -1,9 +1,9 @@ -# Mojo::Pg [](https://travis-ci.org/kraih/mojo-pg) +# Mojo::Pg [](https://travis-ci.com/kraih/mojo-pg) A tiny wrapper around [DBD::Pg](https://metacpan.org/pod/DBD::Pg) that makes - [PostgreSQL](http://www.postgresql.org) a lot of fun to use with the - [Mojolicious](http://mojolicious.org) real-time web framework. + [PostgreSQL](https://www.postgresql.org) a lot of fun to use with the + [Mojolicious](https://mojolicious.org) real-time web framework. ```perl use Mojolicious::Lite -signatures; @@ -52,4 +52,4 @@ ## Want to know more? Take a look at our excellent - [documentation](http://mojolicious.org/perldoc/Mojo/Pg)! + [documentation](https://mojolicious.org/perldoc/Mojo/Pg)! diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/examples/blog/lib/Blog/Controller/Posts.pm new/Mojo-Pg-4.09/examples/blog/lib/Blog/Controller/Posts.pm --- old/Mojo-Pg-4.08/examples/blog/lib/Blog/Controller/Posts.pm 2017-12-14 19:43:40.000000000 +0100 +++ new/Mojo-Pg-4.09/examples/blog/lib/Blog/Controller/Posts.pm 2018-04-04 02:31:11.000000000 +0200 @@ -27,33 +27,32 @@ sub store { my $self = shift; - my $validation = $self->_validation; - return $self->render(action => 'create', post => {}) - if $validation->has_error; + my $v = $self->_validation; + return $self->render(action => 'create', post => {}) if $v->has_error; - my $id = $self->posts->add($validation->output); + my $id = $self->posts->add($v->output); $self->redirect_to('show_post', id => $id); } sub update { my $self = shift; - my $validation = $self->_validation; - return $self->render(action => 'edit', post => {}) if $validation->has_error; + my $v = $self->_validation; + return $self->render(action => 'edit', post => {}) if $v->has_error; my $id = $self->param('id'); - $self->posts->save($id, $validation->output); + $self->posts->save($id, $v->output); $self->redirect_to('show_post', id => $id); } sub _validation { my $self = shift; - my $validation = $self->validation; - $validation->required('title'); - $validation->required('body'); + my $v = $self->validation; + $v->required('title'); + $v->required('body'); - return $validation; + return $v; } 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/lib/Mojo/Pg/Database.pm new/Mojo-Pg-4.09/lib/Mojo/Pg/Database.pm --- old/Mojo-Pg-4.08/lib/Mojo/Pg/Database.pm 2018-01-29 19:25:20.000000000 +0100 +++ new/Mojo-Pg-4.09/lib/Mojo/Pg/Database.pm 2018-08-02 01:00:59.000000000 +0200 @@ -374,6 +374,11 @@ # "insert into t (a) values ('b') on conflict (a) do update set a = 'c'" $db->insert('t', {a => 'b'}, {on_conflict => [a => {a => 'c'}]}); + # "insert into t (a, b) values ('c', 'd') + # on conflict (a, b) do update set a = 'e'" + $db->insert( + 't', {a => 'c', b => 'd'}, {on_conflict => [['a', 'b'] => {a => 'e'}]}); + =head2 insert_p my $promise = $db->insert_p($table, \@values || \%fieldvals, \%options); @@ -511,9 +516,15 @@ # "select foo as bar from some_table" $db->select('some_table', [[foo => 'bar']]); + # "select * from some_table where foo = '[1,2,3]'" + $db->select('some_table', '*', {foo => {'=' => {-json => [1, 2, 3]}}}); + # "select extract(epoch from foo) as foo, bar from some_table" $db->select('some_table', [\'extract(epoch from foo) as foo', 'bar']); + # "select 'test' as foo, bar from some_table" + $db->select('some_table', [\['? as foo', 'test'], 'bar']); + Including a new last argument to pass many new options. # "select * from some_table where foo = 'bar' order by id desc" @@ -595,6 +606,9 @@ # "update some_table set foo = 'bar' where id = 23 returning id" $db->update('some_table', {foo => 'bar'}, {id => 23}, {returning => 'id'}); + # "update some_table set foo = '[1,2,3]' where bar = 23" + $db->update('some_table', {foo => {-json => [1, 2, 3]}}, {bar => 23}); + =head2 update_p my $promise = $db->update_p($table, \%fieldvals, \%where, \%options); @@ -613,6 +627,6 @@ =head1 SEE ALSO -L<Mojo::Pg>, L<Mojolicious::Guides>, L<http://mojolicious.org>. +L<Mojo::Pg>, L<Mojolicious::Guides>, L<https://mojolicious.org>. =cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/lib/Mojo/Pg/Migrations.pm new/Mojo-Pg-4.09/lib/Mojo/Pg/Migrations.pm --- old/Mojo-Pg-4.08/lib/Mojo/Pg/Migrations.pm 2017-12-14 19:43:41.000000000 +0100 +++ new/Mojo-Pg-4.09/lib/Mojo/Pg/Migrations.pm 2018-05-08 13:42:25.000000000 +0200 @@ -243,6 +243,6 @@ =head1 SEE ALSO -L<Mojo::Pg>, L<Mojolicious::Guides>, L<http://mojolicious.org>. +L<Mojo::Pg>, L<Mojolicious::Guides>, L<https://mojolicious.org>. =cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/lib/Mojo/Pg/PubSub.pm new/Mojo-Pg-4.09/lib/Mojo/Pg/PubSub.pm --- old/Mojo-Pg-4.08/lib/Mojo/Pg/PubSub.pm 2018-01-27 02:47:09.000000000 +0100 +++ new/Mojo-Pg-4.09/lib/Mojo/Pg/PubSub.pm 2018-05-08 13:42:32.000000000 +0200 @@ -175,6 +175,6 @@ =head1 SEE ALSO -L<Mojo::Pg>, L<Mojolicious::Guides>, L<http://mojolicious.org>. +L<Mojo::Pg>, L<Mojolicious::Guides>, L<https://mojolicious.org>. =cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/lib/Mojo/Pg/Results.pm new/Mojo-Pg-4.09/lib/Mojo/Pg/Results.pm --- old/Mojo-Pg-4.08/lib/Mojo/Pg/Results.pm 2017-12-17 19:00:44.000000000 +0100 +++ new/Mojo-Pg-4.09/lib/Mojo/Pg/Results.pm 2018-05-08 13:42:43.000000000 +0200 @@ -197,6 +197,6 @@ =head1 SEE ALSO -L<Mojo::Pg>, L<Mojolicious::Guides>, L<http://mojolicious.org>. +L<Mojo::Pg>, L<Mojolicious::Guides>, L<https://mojolicious.org>. =cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/lib/Mojo/Pg/Transaction.pm new/Mojo-Pg-4.09/lib/Mojo/Pg/Transaction.pm --- old/Mojo-Pg-4.08/lib/Mojo/Pg/Transaction.pm 2018-01-26 01:24:06.000000000 +0100 +++ new/Mojo-Pg-4.09/lib/Mojo/Pg/Transaction.pm 2018-05-08 13:42:50.000000000 +0200 @@ -73,6 +73,6 @@ =head1 SEE ALSO -L<Mojo::Pg>, L<Mojolicious::Guides>, L<http://mojolicious.org>. +L<Mojo::Pg>, L<Mojolicious::Guides>, L<https://mojolicious.org>. =cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/lib/Mojo/Pg.pm new/Mojo-Pg-4.09/lib/Mojo/Pg.pm --- old/Mojo-Pg-4.08/lib/Mojo/Pg.pm 2018-01-28 20:04:51.000000000 +0100 +++ new/Mojo-Pg-4.09/lib/Mojo/Pg.pm 2018-05-08 13:42:08.000000000 +0200 @@ -42,7 +42,7 @@ return $pubsub; }; -our $VERSION = '4.08'; +our $VERSION = '4.09'; sub db { $_[0]->database_class->new(dbh => $_[0]->_prepare, pg => $_[0]) } @@ -216,7 +216,7 @@ 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. Perform queries +L<Mojolicious|https://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 @@ -559,6 +559,8 @@ Hernan Lopes +Matt S Trout + Peter Rabbitson William Lindley @@ -575,6 +577,6 @@ =head1 SEE ALSO L<https://github.com/kraih/mojo-pg>, L<Mojolicious::Guides>, -L<http://mojolicious.org>. +L<https://mojolicious.org>. =cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/lib/SQL/Abstract/Pg.pm new/Mojo-Pg-4.09/lib/SQL/Abstract/Pg.pm --- old/Mojo-Pg-4.08/lib/SQL/Abstract/Pg.pm 2018-01-29 19:28:37.000000000 +0100 +++ new/Mojo-Pg-4.09/lib/SQL/Abstract/Pg.pm 2018-08-02 00:59:59.000000000 +0200 @@ -10,26 +10,16 @@ return $self->SUPER::insert($table, $data, $options); } -sub select { - my ($self, $table, $fields, @args) = @_; +sub new { + my $self = shift->SUPER::new(@_); - if (ref $fields eq 'ARRAY') { - my @fields; - for my $field (@$fields) { - if (ref $field eq 'ARRAY') { - puke 'field alias must be in the form [$name => $alias]' if @$field < 2; - push @fields, - $self->_quote($field->[0]) - . $self->_sqlcase(' as ') - . $self->_quote($field->[1]); - } - elsif (ref $field eq 'SCALAR') { push @fields, $$field } - else { push @fields, $self->_quote($field) } - } - $fields = join ', ', @fields; - } + # -json op + push @{$self->{unary_ops}}, { + regex => qr/^json$/, + handler => sub { '?', {json => $_[2]} } + }; - return $self->SUPER::select($table, $fields, @args); + return $self; } sub _insert_returning { @@ -49,8 +39,10 @@ my ($target, $set) = @$conflict; puke 'on_conflict value must be in the form [$target, \%set]' unless ref $set eq 'HASH'; + $target = [$target] unless ref $target eq 'ARRAY'; - $conflict_sql = '(' . $self->_quote($target) . ')'; + $conflict_sql + = '(' . join(', ', map { $self->_quote($_) } @$target) . ')'; $conflict_sql .= $self->_sqlcase(' do update set '); my ($set_sql, @set_bind) = $self->_update_set_values($set); $conflict_sql .= $set_sql; @@ -58,7 +50,7 @@ }, ARRAYREFREF => sub { ($conflict_sql, @conflict_bind) = @$$conflict }, SCALARREF => sub { $conflict_sql = $$conflict }, - UNDEF => sub { $conflict_sql = $self->_sqlcase('do nothing') } + UNDEF => sub { $conflict_sql = $self->_sqlcase('do nothing') } } ); $sql .= $self->_sqlcase(' on conflict ') . $conflict_sql; @@ -135,6 +127,36 @@ return $sql, @bind; } +sub _select_fields { + my ($self, $fields) = @_; + + return $fields unless ref $fields eq 'ARRAY'; + + my (@fields, @bind); + for my $field (@$fields) { + $self->_SWITCH_refkind( + $field => { + ARRAYREF => sub { + puke 'field alias must be in the form [$name => $alias]' + if @$field < 2; + push @fields, + $self->_quote($field->[0]) + . $self->_sqlcase(' as ') + . $self->_quote($field->[1]); + }, + ARRAYREFREF => sub { + push @fields, shift @$$field; + push @bind, @$$field; + }, + SCALARREF => sub { push @fields, $$field }, + FALLBACK => sub { push @fields, $self->_quote($field) } + } + ); + } + + return join(', ', @fields), @bind; +} + sub _table { my ($self, $table) = @_; @@ -183,6 +205,17 @@ L<SQL::Abstract::Pg> extends L<SQL::Abstract> with a few PostgreSQL features used by L<Mojo::Pg>. +=head2 JSON + +In many places (as supported by L<SQL::Abstract>) you can use the C<-json> unary +op to encode JSON from Perl data structures. + + # "update some_table set foo = '[1,2,3]' where bar = 23" + $abstract->update('some_table', {foo => {-json => [1, 2, 3]}}, {bar => 23}); + + # "select * from some_table where foo = '[1,2,3]'" + $abstract->select('some_table', '*', {foo => {'=' => {-json => [1, 2, 3]}}}); + =head1 INSERT $abstract->insert($table, \@values || \%fieldvals, \%options); @@ -206,6 +239,11 @@ # "insert into t (a) values ('b') on conflict (a) do update set a = 'c'" $abstract->insert('t', {a => 'b'}, {on_conflict => [a => {a => 'c'}]}); + # "insert into t (a, b) values ('c', 'd') + # on conflict (a, b) do update set a = 'e'" + $abstract->insert( + 't', {a => 'c', b => 'd'}, {on_conflict => [['a', 'b'] => {a => 'e'}]}); + # "insert into t (a) values ('b') on conflict (a) do update set a = 'c'" $abstract->insert( 't', {a => 'b'}, {on_conflict => \['(a) do update set a = ?', 'c']}); @@ -219,7 +257,8 @@ The C<$fields> argument now also accepts array references containing array references with field names and aliases, as well as array references containing -scalar references to pass literal SQL. +scalar references to pass literal SQL and array reference references to pass +literal SQL with bind values. # "select foo as bar from some_table" $abstract->select('some_table', [[foo => 'bar']]); @@ -230,6 +269,9 @@ # "select extract(epoch from foo) as foo, bar from some_table" $abstract->select('some_table', [\'extract(epoch from foo) as foo', 'bar']); + # "select 'test' as foo, bar from some_table" + $abstract->select('some_table', [\['? as foo', 'test'], 'bar']); + =head2 JOIN The C<$source> argument now also accepts array references containing not only @@ -309,6 +351,6 @@ =head1 SEE ALSO -L<Mojo::Pg>, L<Mojolicious::Guides>, L<http://mojolicious.org>. +L<Mojo::Pg>, L<Mojolicious::Guides>, L<https://mojolicious.org>. =cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/t/crud.t new/Mojo-Pg-4.09/t/crud.t --- old/Mojo-Pg-4.08/t/crud.t 2018-01-29 19:24:45.000000000 +0100 +++ new/Mojo-Pg-4.09/t/crud.t 2018-08-02 00:58:56.000000000 +0200 @@ -33,7 +33,7 @@ $db->insert('crud_test', {id => 1, name => 'foo'}, {on_conflict => undef}); $db->insert( 'crud_test', - {id => 2, name => 'bar'}, + {id => 2, name => 'bar'}, {on_conflict => [id => {name => 'baz'}]} ); @@ -117,12 +117,10 @@ $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'"); -Mojo::Promise->all($first, $second)->then( - sub { - my ($first, $second) = @_; - $result = [$first->[0]->hash, $second->[0]->hash]; - } -)->wait; +Mojo::Promise->all($first, $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; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/t/database.t new/Mojo-Pg-4.09/t/database.t --- old/Mojo-Pg-4.08/t/database.t 2017-12-16 16:37:38.000000000 +0100 +++ new/Mojo-Pg-4.09/t/database.t 2018-02-19 00:54:41.000000000 +0100 @@ -243,12 +243,10 @@ push @notifications, [$name, $pid, $payload]; $db2->once(notification => $delay->begin); my $tx = $db2->begin; - Mojo::IOLoop->next_tick( - sub { - $db2->notify(dbtest2 => 'baz'); - $tx->commit; - } - ); + Mojo::IOLoop->next_tick(sub { + $db2->notify(dbtest2 => 'baz'); + $tx->commit; + }); }, sub { my ($delay, $name, $pid, $payload) = @_; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/t/pod_coverage.t new/Mojo-Pg-4.09/t/pod_coverage.t --- old/Mojo-Pg-4.08/t/pod_coverage.t 2018-01-28 15:13:40.000000000 +0100 +++ new/Mojo-Pg-4.09/t/pod_coverage.t 2018-03-17 23:38:52.000000000 +0100 @@ -7,8 +7,8 @@ plan skip_all => 'Test::Pod::Coverage 1.04+ required for this test!' unless eval 'use Test::Pod::Coverage 1.04; 1'; -my %RULES - = ('SQL::Abstract::Pg' => {also_private => ['insert', 'puke', 'select']},); +my $private = ['insert', 'new', 'puke', 'select']; +my %RULES = ('SQL::Abstract::Pg' => {also_private => $private},); pod_coverage_ok($_, $RULES{$_} || {}) for all_modules(); done_testing(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/t/pubsub.t new/Mojo-Pg-4.09/t/pubsub.t --- old/Mojo-Pg-4.08/t/pubsub.t 2017-06-24 15:01:30.000000000 +0200 +++ new/Mojo-Pg-4.09/t/pubsub.t 2018-02-19 00:54:40.000000000 +0100 @@ -45,14 +45,12 @@ push @raw, $payload; } ); -Mojo::IOLoop->next_tick( - sub { - $pg->db->notify(pstest => 'fail'); - $pg->pubsub->notify('pstest')->notify(pstest => {msg => '♥works♥'}) - ->notify(pstest => [1, 2, 3])->notify(pstest => true) - ->notify(pstest2 => '♥works♥')->notify(pstest => {msg => 'stop'}); - } -); +Mojo::IOLoop->next_tick(sub { + $pg->db->notify(pstest => 'fail'); + $pg->pubsub->notify('pstest')->notify(pstest => {msg => '♥works♥'}) + ->notify(pstest => [1, 2, 3])->notify(pstest => true) + ->notify(pstest2 => '♥works♥')->notify(pstest => {msg => 'stop'}); +}); Mojo::IOLoop->start; is_deeply \@json, [undef, undef, {msg => '♥works♥'}, [1, 2, 3], true, {msg => 'stop'}], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojo-Pg-4.08/t/sql.t new/Mojo-Pg-4.09/t/sql.t --- old/Mojo-Pg-4.08/t/sql.t 2018-01-29 19:24:41.000000000 +0100 +++ new/Mojo-Pg-4.09/t/sql.t 2018-08-02 00:58:59.000000000 +0200 @@ -55,6 +55,17 @@ 'baz', 'yada' ]; is_deeply \@sql, $result, 'right query'; +@sql = $abstract->insert( + 'foo', + {bar => 'baz'}, + {on_conflict => [['foo', 'bar'] => {foo => 'yada'}]} +); +$result = [ + 'INSERT INTO "foo" ( "bar") VALUES ( ? )' + . ' ON CONFLICT ("foo", "bar") DO UPDATE SET "foo" = ?', + 'baz', 'yada' +]; +is_deeply \@sql, $result, 'right query'; # ON CONFLICT (unsupported value) eval { $abstract->insert('foo', {bar => 'baz'}, {on_conflict => [[], []]}) }; @@ -92,7 +103,7 @@ 'right query'; @sql = $abstract->select( 'foo', '*', - {bar => {'>' => 'baz'}}, + {bar => {'>' => 'baz'}}, {group_by => ['bar'], having => {baz => {'<' => 'bar'}}} ); $result = [ @@ -126,12 +137,24 @@ is_deeply \@sql, ['SELECT "bar", extract(epoch from baz) as baz, "yada" FROM "foo"'], 'right query'; +@sql = $abstract->select('foo', ['bar', \['? as baz', 'test'], 'yada']); +is_deeply \@sql, ['SELECT "bar", ? as baz, "yada" FROM "foo"', 'test'], + 'right query'; # AS (unsupported value) eval { $abstract->select('foo', [[]]) }; like $@, qr/field alias must be in the form \[\$name => \$alias\]/, 'right error'; +# JSON +@sql = $abstract->update('foo', {bar => {-json => [1, 2, 3]}}); +is_deeply \@sql, ['UPDATE "foo" SET "bar" = ?', {json => [1, 2, 3]}], + 'right query'; +@sql = $abstract->select('foo', '*', {bar => {'=' => {-json => [1, 2, 3]}}}); +is_deeply \@sql, + ['SELECT * FROM "foo" WHERE ( "bar" = ? )', {json => [1, 2, 3]}], + 'right query'; + # JOIN @sql = $abstract->select(['foo', ['bar', foo_id => 'id']]); is_deeply \@sql, @@ -141,8 +164,9 @@ is_deeply \@sql, ['SELECT * FROM "foo" JOIN "bar" ON ("foo"."id" = "bar"."foo_id")'], 'right query'; -@sql = $abstract->select( - ['foo', ['bar', foo_id => 'id'], ['baz', foo_id => 'id']]); +@sql + = $abstract->select(['foo', ['bar', foo_id => 'id'], ['baz', foo_id => 'id'] + ]); $result = [ 'SELECT * FROM "foo"' . ' JOIN "bar" ON ("bar"."foo_id" = "foo"."id")'
