diff -Nru libpgobject-simple-role-perl-1.13.2/Changes libpgobject-simple-role-perl-2.000002/Changes --- libpgobject-simple-role-perl-1.13.2/Changes 2016-11-21 17:33:47.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/Changes 2017-05-20 17:11:57.000000000 +0000 @@ -1,5 +1,16 @@ Revision history for PGObject-Simple-Role +2.0.2 2017-05-20 + Fixing backwards compatibility issue with _DBH in constructor + +2.0.1 2017-05-20 + Fixing an issue where package accessors do not provide package defaults + +2.0 2017-05-19 + Depending now on PGObject::Simple 3 + No more code duplication + We share state with PGObject functions + New architecture. 1.13.2 2016-11-21 Fix minimum required dependency diff -Nru libpgobject-simple-role-perl-1.13.2/debian/changelog libpgobject-simple-role-perl-2.000002/debian/changelog --- libpgobject-simple-role-perl-1.13.2/debian/changelog 2016-11-28 20:39:03.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/debian/changelog 2017-07-10 12:51:23.000000000 +0000 @@ -1,3 +1,17 @@ +libpgobject-simple-role-perl (2.000002-1) unstable; urgency=medium + + * Team upload. + * Import upstream version 2.000002 + * Update years of upstream copyright + * Update Debian packaging copyright + * debian/copyright: use https:// in Source field + * Bump debhelper compatibility level to 10 + * Declare compliance with Debian Policy 4.0.0 + * Update version constraint of build and runtime dependency on + libpgobject-simple-perl + + -- Lucas Kanashiro Mon, 10 Jul 2017 09:51:23 -0300 + libpgobject-simple-role-perl (1.13.2-1) unstable; urgency=medium * Team upload. diff -Nru libpgobject-simple-role-perl-1.13.2/debian/compat libpgobject-simple-role-perl-2.000002/debian/compat --- libpgobject-simple-role-perl-1.13.2/debian/compat 2016-11-28 20:39:03.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/debian/compat 2017-07-10 12:51:23.000000000 +0000 @@ -1 +1 @@ -9 +10 diff -Nru libpgobject-simple-role-perl-1.13.2/debian/control libpgobject-simple-role-perl-2.000002/debian/control --- libpgobject-simple-role-perl-1.13.2/debian/control 2016-11-28 20:39:03.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/debian/control 2017-07-10 12:51:23.000000000 +0000 @@ -4,14 +4,14 @@ Section: perl Testsuite: autopkgtest-pkg-perl Priority: optional -Build-Depends: debhelper (>= 9) +Build-Depends: debhelper (>= 10) Build-Depends-Indep: libmoo-perl, libtest-pod-perl, libtest-pod-coverage-perl, libtest-exception-perl, - libpgobject-simple-perl (>= 2.0.0), + libpgobject-simple-perl (>= 3), perl -Standards-Version: 3.9.8 +Standards-Version: 4.0.0 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-perl/packages/libpgobject-simple-role-perl.git Vcs-Git: https://anonscm.debian.org/git/pkg-perl/packages/libpgobject-simple-role-perl.git Homepage: http://metacpan.org/release/PGObject-Simple-Role @@ -21,7 +21,7 @@ Depends: ${misc:Depends}, ${perl:Depends}, libmoo-perl, - libpgobject-simple-perl (>= 2.0.0) + libpgobject-simple-perl (>= 3) Recommends: libpgobject-util-dbmethod-perl Description: Moo/Moose mappers for minimalist PGObject framework PGObject::Simple::Role is a Moo/Moose mapper for minimalist PGObject framework diff -Nru libpgobject-simple-role-perl-1.13.2/debian/copyright libpgobject-simple-role-perl-2.000002/debian/copyright --- libpgobject-simple-role-perl-1.13.2/debian/copyright 2016-11-28 20:39:03.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/debian/copyright 2017-07-10 12:51:23.000000000 +0000 @@ -1,17 +1,17 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: PGObject-Simple-Role Upstream-Contact: Chris Travers -Source: http://metacpan.org/release/PGObject-Simple-Role +Source: https://metacpan.org/release/PGObject-Simple-Role Files: * -Copyright: 2013-2014, Chris Travers +Copyright: 2013-2017, Chris Travers License: BSD-2-clause Files: debian/* Copyright: 2013-2014, Robert James Clay 2014, Salvatore Bonaccorso 2013, Axel Beckert - 2016, Lucas Kanashiro + 2016-2017, Lucas Kanashiro License: BSD-2-clause or Artistic or GPL-1+ License: BSD-2-clause diff -Nru libpgobject-simple-role-perl-1.13.2/lib/PGObject/Simple/Role.pm libpgobject-simple-role-perl-2.000002/lib/PGObject/Simple/Role.pm --- libpgobject-simple-role-perl-1.13.2/lib/PGObject/Simple/Role.pm 2016-11-21 20:07:13.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/lib/PGObject/Simple/Role.pm 2017-05-20 17:24:09.000000000 +0000 @@ -1,10 +1,10 @@ package PGObject::Simple::Role; -use 5.006; +use 5.010; use strict; use warnings; use Moo::Role; -use PGObject::Simple; +use PGObject::Simple ':full', '!dbh'; use Carp; =head1 NAME @@ -13,12 +13,11 @@ =head1 VERSION -Version 1.13.2 +Version 2.0.2 =cut -our $VERSION = '1.13.2'; - +our $VERSION = 2.000002; =head1 SYNOPSIS @@ -68,11 +67,11 @@ =head1 ATTRIBUTES AND LAZY GETTERS + =cut -# Private attribute for database handle, not intended to be directly set. -has _DBH => ( +has _dbh => ( # use dbh() to get and set_dbh() to set is => 'lazy', isa => sub { croak "Expected a database handle. Got $_[0] instead" @@ -80,15 +79,37 @@ }, ); -sub _build__DBH { +has _DBH => ( # backwards compatible for 1.x. + is => 'lazy', + isa => sub { + warn 'deprecated _DBH used. rename to _dbh when you can'; + croak "Expected a database handle. Got $_[0] instead" + unless eval {$_[0]->isa('DBI::db')}; + }, +); + +sub _build__dbh { my ($self) = @_; + return $self->{_DBH} if $self->{_DBH}; return $self->_get_dbh; } -has _Registry => (is => 'lazy'); +sub _build__DBH { + my ($self) = @_; + return $self->{_dbh} if $self->{_dbh}; + return $self->_dbh; +} + +sub _get_dbh { + croak 'Invoked _get_dbh from role improperly. Subclasses MUST set this method'; +} + +has _registry => (is => 'lazy'); -sub _build__Registry { - return _get_registry(); +sub _build__registry { + my ($self) = @_; + return $self->_get_registry() if $self->can('_get_registry'); + _get_registry(); } =head2 _get_registry @@ -128,127 +149,54 @@ =cut sub _build__funcprefix { - return $_[0]->_get_prefix; + my ($self) = @_; + return $self->_get_prefix; } sub _get_prefix { return ''; } -has _PGObject_Simple => ( - is => 'lazy', -); +=head1 READ ONLY ACCESSORS (PUBLIC) -sub _build__PGObject_Simple { - my ($self) = @_; - return PGObject::Simple->new() unless ref $self; - $self->_DBH; - $self->_funcprefix; - my $obj = PGObject::Simple->new(%$self); - $obj->_set_registry($self->_registry); - return $obj; -} +=head2 dbh -has _registry => ( is => 'lazy' ); - -sub _build__registry { - return _get_registry(); -} - -=head2 _get_dbh - -Subclasses or sub-roles MUST implement a function which returns a DBI database -handle (DBD::Pg 2.0 or hgher required). If this is not overridden an exception -will be raised. +Wraps the PGObject::Simple method =cut -sub _get_dbh { - croak 'Subclasses MUST set their own get_dbh methods!'; +sub dbh { + my ($self) = @_; + if (ref $self){ + return $self->_dbh; + } + return "$self"->_get_dbh; } -=head2 call_procedure +=head2 funcschema -Identical to PGObject::Simple::call_procedure +Returns the schema bound to the object =cut -sub call_procedure { - my $self = shift @_; - my %args = @_; - my $obj = _build__PGObject_Simple($self); - $obj->{_DBH} = $self->_DBH if ref $self and !$args{dbh}; - $obj->{_DBH} = "$self"->_get_dbh unless ref $self or $args{dbh}; - if (ref $self){ - $args{funcprefix} = $self->_funcprefix - unless defined $args{funcprefix} or !ref $self; - $args{funcschema} = $self->_funcschema - unless defined $args{funcschema} or !ref $self; - } else { - $args{funcprefix} = "$self"->_get_prefix - unless defined $args{funcprefix} or ref $self; - $args{funcschema} = "$self"->_get_schema - unless defined $args{funcschema} or ref $self; - } - my @rows = $obj->call_procedure(%args); - for my $row (@rows){ - for (keys %$row){ - delete $row->{$_} unless defined $row->{$_}; - } - } - return @rows if wantarray; - return shift @rows; +sub funcschema { + my ($self) = @_; + return $self->_funcschema if ref $self; + return "$self"->_get_schema(); } -=head2 call_dbmethod +=head2 funcprefix -Identical interface to PGObject::Simple->call_dbmethod - -This can be used on objects or on the packages themselves. I.e. -mypackage->call_dbmethod() and $myobject->call_dbmethod() both work. +Prefix for functions =cut -sub call_dbmethod { - my $self = shift @_; - my %args = @_; - croak 'No function name provided' unless $args{funcname}; - - $args{dbh} = $self->_DBH if ref $self and !$args{dbh}; - $args{dbh} = "$self"->_get_dbh() unless $args{dbh}; - if (ref $self){ - $args{funcprefix} = $self->_funcprefix unless defined $args{funcprefix}; - $args{funcschema} = $self->_funcschema unless $args{funcschema}; - } else { - $args{funcprefix} = "$self"->_get_prefix - unless defined $args{funcprefix}; - $args{funcschema} = "$self"->_get_schema unless $args{funcschema}; - } - $args{funcprefix} ||= ''; - - my $info = PGObject->function_info(%args); - - my $dbargs = []; - @$dbargs = map { - my $argname = $_->{name}; - my $db_arg; - $argname =~ s/^in_//; - local $@; - eval { $db_arg = $self->can($argname)->($self) } - if ref $self and $argname; - $db_arg = $args{args}->{$argname} if exists $args{args}->{$argname}; - $db_arg; - } @{$info->{args}}; - $args{args} = $dbargs; - my @rows; - if (ref $self){ - @rows = $self->call_procedure(%args); - } else { - @rows = "$self"->call_procedure(%args); - } - return @rows if wantarray; - return shift @rows; -} +sub funcprefix { + my ($self) = @_; + + return $self->_funcprefix if ref $self; + return "$self"->_get_prefix(); +} =head1 REMOVED METHODS @@ -325,7 +273,7 @@ =head1 LICENSE AND COPYRIGHT -Copyright 2013-2014 Chris Travers,. +Copyright 2013-2017 Chris Travers,. Redistribution and use in source and compiled forms with or without modification, are permitted provided that the following conditions are met: diff -Nru libpgobject-simple-role-perl-1.13.2/Makefile.PL libpgobject-simple-role-perl-2.000002/Makefile.PL --- libpgobject-simple-role-perl-1.13.2/Makefile.PL 2016-11-21 20:06:22.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/Makefile.PL 2017-05-13 11:36:47.000000000 +0000 @@ -1,6 +1,6 @@ #!/usr/bin/perl -use 5.006; +use 5.010; use strict; use warnings; use ExtUtils::MakeMaker; @@ -17,7 +17,7 @@ PREREQ_PM => { 'Test::More' => 0, 'Moo::Role' => 0, - 'PGObject::Simple' => '2.0.0', + 'PGObject::Simple' => 3, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'PGObject-Simple-Role-*' }, diff -Nru libpgobject-simple-role-perl-1.13.2/MANIFEST.SKIP libpgobject-simple-role-perl-2.000002/MANIFEST.SKIP --- libpgobject-simple-role-perl-1.13.2/MANIFEST.SKIP 2016-11-21 16:57:49.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/MANIFEST.SKIP 2017-05-13 11:38:08.000000000 +0000 @@ -2,9 +2,9 @@ #!start included /usr/lib/perl5/5.10/ExtUtils/MANIFEST.SKIP # Avoid version control files. \B\.svn\b -\B\.hg\b \B\.git\b \B\.gitignore\b +\B\.hg\b \B\.travis\.yml\b # Avoid Makemaker generated and utility files. @@ -37,6 +37,7 @@ ^tmp \bTAGS$ ^MYMETA.yml$ +^MYMETA.json$ \bSu-[\d\.\_]+ diff -Nru libpgobject-simple-role-perl-1.13.2/META.json libpgobject-simple-role-perl-2.000002/META.json --- libpgobject-simple-role-perl-1.13.2/META.json 2016-11-21 20:08:24.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/META.json 2017-05-20 17:28:20.000000000 +0000 @@ -4,7 +4,7 @@ "Chris Travers, " ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.150005", + "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150005", "license" : [ "bsd" ], @@ -33,12 +33,12 @@ "runtime" : { "requires" : { "Moo::Role" : "0", - "PGObject::Simple" : "v2.0.0", + "PGObject::Simple" : "3", "Test::More" : "0" } } }, "release_status" : "stable", - "version" : "v1.13.2", - "x_serialization_backend" : "JSON::PP version 2.27300" + "version" : 2.000002, + "x_serialization_backend" : "JSON::PP version 2.27400" } diff -Nru libpgobject-simple-role-perl-1.13.2/META.yml libpgobject-simple-role-perl-2.000002/META.yml --- libpgobject-simple-role-perl-1.13.2/META.yml 2016-11-21 20:08:24.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/META.yml 2017-05-20 17:28:20.000000000 +0000 @@ -7,7 +7,7 @@ configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.150005' +generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150005' license: bsd meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -19,7 +19,7 @@ - inc requires: Moo::Role: '0' - PGObject::Simple: v2.0.0 + PGObject::Simple: '3' Test::More: '0' -version: v1.13.2 -x_serialization_backend: 'CPAN::Meta::YAML version 0.012' +version: 2.000002 +x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -Nru libpgobject-simple-role-perl-1.13.2/README.md libpgobject-simple-role-perl-2.000002/README.md --- libpgobject-simple-role-perl-1.13.2/README.md 2016-11-21 16:56:17.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/README.md 2017-05-13 11:41:39.000000000 +0000 @@ -47,7 +47,7 @@ LICENSE AND COPYRIGHT -Copyright (C) 2013 Chris Travers +Copyright (C) 2013-2017 Chris Travers Redistribution and use in source and compiled forms with or without modification, are permitted provided that the following conditions are met: diff -Nru libpgobject-simple-role-perl-1.13.2/t/01-basic-constructor.t libpgobject-simple-role-perl-2.000002/t/01-basic-constructor.t --- libpgobject-simple-role-perl-1.13.2/t/01-basic-constructor.t 2016-11-21 16:56:17.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/t/01-basic-constructor.t 2017-05-13 16:26:08.000000000 +0000 @@ -1,4 +1,3 @@ - ######### package test1; @@ -20,11 +19,13 @@ return 1; } +sub _get_prefix { 'foo' }; + ########## package main; -use Test::More tests => 10; +use Test::More tests => 14; use Test::Exception; use DBI; @@ -41,13 +42,17 @@ lives_ok {$obj = test1->new(%args)} 'created new object without crashing'; ok(eval {$obj->isa('test1')}, 'ISA test passed'); is($obj->id, 3, 'attribute id passed'); +is($obj->funcprefix, '', 'Got correct function prefix(empty)'); +is($obj->_registry, undef, 'Undefined registry at first'); is($obj->foo, 'test1', 'attribute foo passed'); is($obj->bar, 'test2', 'attribute bar passed'); is($obj->baz, 33, 'attribute baz passed'); ok(!defined($obj->can('biz')), 'No dbh method exists'); -throws_ok {$obj->_build__DBH(1)} qr/Subclasses MUST set/, +throws_ok {$obj->_build__dbh(1)} qr/Subclasses MUST set/, 'Threw exception, "Subclasses MUST set"'; lives_ok {$obj = test2->new(%args)} 'created new object without crashing'; -throws_ok {$obj->_DBH} qr/Expected a database handle/, +is($obj->funcprefix, 'foo', 'Got correct function prefix'); +throws_ok {$obj->_dbh} qr/Expected a database handle/, 'Threw exception, "Expected a database handle"'; +lives_ok {$obj->set_dbh(4) } 'set-dbh goes through isa check'; diff -Nru libpgobject-simple-role-perl-1.13.2/t/02-dbtests.t libpgobject-simple-role-perl-2.000002/t/02-dbtests.t --- libpgobject-simple-role-perl-1.13.2/t/02-dbtests.t 2016-11-21 16:56:17.000000000 +0000 +++ libpgobject-simple-role-perl-2.000002/t/02-dbtests.t 2017-05-20 17:17:55.000000000 +0000 @@ -37,6 +37,14 @@ return 'foo'; }; +package test3; +use Moo; +with 'PGObject::Simple::Role'; + +sub _get_dbh { + return 1; +} + package main; use Test::More; @@ -57,7 +65,7 @@ our $dbh = DBI->connect('dbi:Pg:dbname=pgobject_test_db', 'postgres'); plan skip_all => 'No db connection' unless $dbh; -plan tests => 17; +plan tests => 27; $dbh->do(' CREATE FUNCTION public.foobar (in_foo text, in_bar text, in_baz int, in_id int) @@ -78,14 +86,17 @@ SELECT char_length($1) + char_length($2) + $3 * $4; $$; ') ; - -my ($result) = test->call_dbmethod( +my $result; +lives_ok { $result = test->call_dbmethod( funcname => 'foobar', args => {id => 3, foo => 'test1', bar => 'test2', baz => 33}, -); +)} 'Able to call without instantiating'; is($result->{foobar}, 109, 'Correct Result, direct package call to call_dbmethod'); my $obj = test->new(id => 3, foo => 'test1', bar => 'test2', baz => 33); +is($obj->_dbh, $dbh, 'Got correct dbh for obj via semiprivate attribute'); +is($obj->dbh, $dbh, 'Got correct dbh for obj via public reader'); + ($result) = $obj->call_dbmethod(funcname => 'foobar'); is($result->{foobar}, 109, 'Correct Result, no argument overrides'); $result = $obj->call_dbmethod(funcname => 'lazy_foobar'); @@ -115,6 +126,7 @@ throws_ok{$obj->call_dbmethod(funcname => 'foobar', dbh => $dbh1)} qr/No such function/, 'No such function thrown using wrong db'; $obj = test2->new(id => 3, foo => 'test1', bar => 'test2', baz => 33); +is($obj->funcprefix, 'foo', 'public printer returns correct value'); ($result) = $obj->call_dbmethod(funcname => 'bar'); @@ -137,6 +149,17 @@ throws_ok{$obj->call_dbmethod(funcname => 'bar', dbh => $dbh1)} qr/No such function/, 'No such function thrown using wrong db'; +dies_ok { test3->new()->_dbh } 'test3 has a bad _get_dbh function, dies by default'; + +dies_ok { test3->new()->dbh } 'test3 has a bad _get_dbh function, dies by default getting dbh'; + +lives_ok { $obj = test3->new(_DBH => $dbh) } 'test3 has a bad _get_dbh function, but can set dbh via _DBH'; + +is($obj->dbh, $dbh, 'Got correct dbh back from _DBH'); + +lives_ok { $obj = test3->new(_dbh => $dbh) } 'test3 has a bad _get_dbh function, but can set via _dbh'; + +is($obj->dbh, $dbh, 'Got correct dbh back from _dbh'); # Teardown connections $dbh->disconnect; $dbh1->do('DROP DATABASE pgobject_test_db');