r26733 - in /branches/upstream/librose-db-object-perl/current: Changes META.yml Makefile.PL lib/Rose/DB/Object.pm lib/Rose/DB/Object/Helpers.pm t/00-warning.t t/as-tree.t t/db-object-helpers.t
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Mon Nov 10 09:05:52 UTC 2008
Author: eloy
Date: Mon Nov 10 09:05:50 2008
New Revision: 26733
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=26733
Log:
[svn-upgrade] Integrating new upstream version, librose-db-object-perl (0.775)
Modified:
branches/upstream/librose-db-object-perl/current/Changes
branches/upstream/librose-db-object-perl/current/META.yml
branches/upstream/librose-db-object-perl/current/Makefile.PL
branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object.pm
branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Helpers.pm
branches/upstream/librose-db-object-perl/current/t/00-warning.t
branches/upstream/librose-db-object-perl/current/t/as-tree.t
branches/upstream/librose-db-object-perl/current/t/db-object-helpers.t
Modified: branches/upstream/librose-db-object-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/librose-db-object-perl/current/Changes?rev=26733&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/Changes (original)
+++ branches/upstream/librose-db-object-perl/current/Changes Mon Nov 10 09:05:50 2008
@@ -1,3 +1,11 @@
+0.775 (11.02.2008) - John Siracusa <siracusa at gmail.com>
+
+ * The insert_or_update(), load_or_insert(), and load_or_save() helper
+ methods no longer throw an exception when called on an object with
+ no uniquely identifying column(s). (Suggested by Richard Jones)
+ * Added detection of minimum JSON version (2.00) to test suite and
+ the Helpers module.
+
0.774 (10.25.2008) - John Siracusa <siracusa at gmail.com>
* Setting objects related through a one-to-many relationship
@@ -7,8 +15,8 @@
"strict mode" quirk (or, IMO, "bug") which causes it to complain
about a situation that is only a concern if it decided to do an
INSERT rather than an UPDATE. (Reported by Richard Jones)
- * Fixed a regression ( t/spot-check-10.t) that caused adding objects
- to one-to-many-related lists to fail under some circumstances.
+ * Fixed a regression in t/spot-check-10.t: adding objects to
+ one-to-many-related lists failed in some circumstances.
* Updated auto-initialization examples in the synopsis.
0.773 (10.02.2008) - John Siracusa <siracusa at gmail.com>
Modified: branches/upstream/librose-db-object-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/librose-db-object-perl/current/META.yml?rev=26733&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/META.yml (original)
+++ branches/upstream/librose-db-object-perl/current/META.yml Mon Nov 10 09:05:50 2008
@@ -1,8 +1,9 @@
--- #YAML:1.0
name: Rose-DB-Object
-version: 0.774
-abstract: ~
-author: []
+version: 0.775
+abstract: Extensible, high performance object-relational mapper (ORM).
+author:
+ - John Siracusa <siracusa at gmail.com>
license: perl
distribution_type: module
configure_requires:
Modified: branches/upstream/librose-db-object-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/librose-db-object-perl/current/Makefile.PL?rev=26733&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/Makefile.PL (original)
+++ branches/upstream/librose-db-object-perl/current/Makefile.PL Mon Nov 10 09:05:50 2008
@@ -10,8 +10,9 @@
die $@ if($@);
}
-WriteMakefile(NAME => 'Rose::DB::Object',
- VERSION_FROM => 'lib/Rose/DB/Object.pm',
+WriteMakefile(NAME => 'Rose::DB::Object',
+ ABSTRACT_FROM => 'lib/Rose/DB/Object.pm',
+ VERSION_FROM => 'lib/Rose/DB/Object.pm',
($^O =~ /darwin/i ? (dist => { DIST_CP => 'cp' }) : ()), # Avoid Mac OS X ._* files
PREREQ_PM =>
{
@@ -34,6 +35,7 @@
'Rose::DB' => '0.745',
},
clean => { FILES => "t/*.db" },
+ AUTHOR => 'John Siracusa <siracusa at gmail.com>',
($MM_Version >= 6.48 ? (MIN_PERL_VERSION => '5.6.0') : ()),
($MM_Version >= 6.31 ? (LICENSE => 'perl') : ()),
($MM_Version <= 6.44 ? () :
Modified: branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object.pm?rev=26733&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object.pm (original)
+++ branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object.pm Mon Nov 10 09:05:50 2008
@@ -16,7 +16,7 @@
use Rose::DB::Object::Exception;
use Rose::DB::Object::Util();
-our $VERSION = '0.774';
+our $VERSION = '0.775';
our $Debug = 0;
Modified: branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Helpers.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Helpers.pm?rev=26733&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Helpers.pm (original)
+++ branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Helpers.pm Mon Nov 10 09:05:50 2008
@@ -11,7 +11,7 @@
use Carp;
-our $VERSION = '0.772';
+our $VERSION = '0.775';
__PACKAGE__->export_tags
(
@@ -79,6 +79,10 @@
sub init_json_encoder
{
require JSON;
+
+ croak "JSON version 2.00 or later is required. You have $JSON::VERSION"
+ unless($JSON::VERSION >= 2.00);
+
return JSON->new->utf8->space_after;
}
@@ -96,16 +100,35 @@
my($ret, @ret);
- if(wantarray)
- {
- @ret = $self->load(@_, speculative => 1);
- return @ret if($ret[0]);
- }
- else
- {
- $ret = $self->load(@_, speculative => 1);
- return $ret if($ret);
- }
+ # Ignore any errors due to missing primary/unique keys
+ my $loaded = eval
+ {
+ if(wantarray)
+ {
+ @ret = $self->load(@_, speculative => 1);
+ return $ret[0] if($ret[0]); # return from eval
+ }
+ else
+ {
+ $ret = $self->load(@_, speculative => 1);
+ return $ret if($ret); # return from eval
+ }
+
+ return 0; # return from eval
+ };
+
+ if(my $error = $@)
+ {
+ # ...but re-throw all other errors
+ unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+ $error->code == EXCEPTION_CODE_NO_KEY)
+ {
+ $self->meta->handle_error($self);
+ return 0;
+ }
+ }
+
+ return wantarray ? @ret : $ret if($loaded);
return $self->insert;
}
@@ -116,16 +139,35 @@
my($ret, @ret);
- if(wantarray)
- {
- @ret = $self->load(@_, speculative => 1);
- return @ret if($ret[0]);
- }
- else
- {
- $ret = $self->load(@_, speculative => 1);
- return $ret if($ret);
- }
+ # Ignore any errors due to missing primary/unique keys
+ my $loaded = eval
+ {
+ if(wantarray)
+ {
+ @ret = $self->load(@_, speculative => 1);
+ return $ret[0] if($ret[0]); # return from eval
+ }
+ else
+ {
+ $ret = $self->load(@_, speculative => 1);
+ return $ret if($ret); # return from eval
+ }
+
+ return 0; # return from eval
+ };
+
+ if(my $error = $@)
+ {
+ # ...but re-throw all other errors
+ unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+ $error->code == EXCEPTION_CODE_NO_KEY)
+ {
+ $self->meta->handle_error($self);
+ return 0;
+ }
+ }
+
+ return wantarray ? @ret : $ret if($loaded);
return $self->save;
}
@@ -150,7 +192,23 @@
# ...but this is a lot faster
my $clone = bless { %$self }, ref($self);
- if($clone->load(speculative => 1))
+ my $loaded;
+
+ # Ignore any errors due to missing primary/unique keys
+ eval { $loaded = $clone->load(speculative => 1) };
+
+ if(my $error = $@)
+ {
+ # ...but re-throw all other errors
+ unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+ $error->code == EXCEPTION_CODE_NO_KEY)
+ {
+ $meta->handle_error($self);
+ return 0;
+ }
+ }
+
+ if($loaded)
{
# The long way...
my %pk;
Modified: branches/upstream/librose-db-object-perl/current/t/00-warning.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/librose-db-object-perl/current/t/00-warning.t?rev=26733&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/t/00-warning.t (original)
+++ branches/upstream/librose-db-object-perl/current/t/00-warning.t Mon Nov 10 09:05:50 2008
@@ -10,15 +10,16 @@
eval { require DBD::SQLite };
eval { require DBD::Informix };
eval { require DBD::Oracle };
+eval { require JSON };
print STDERR "\n##\n";
-foreach my $pkg (qw(DBI DBD::Pg DBD::mysql DBD::SQLite DBD::Informix DBD::Oracle ))
+foreach my $pkg (qw(DBI DBD::Pg DBD::mysql DBD::SQLite DBD::Informix DBD::Oracle JSON))
{
no strict 'refs';
if(defined(my $version = ${$pkg . '::VERSION'}))
{
- print STDERR sprintf("## %-15s %s\n", $pkg, $version);
+ print STDERR sprintf("## %-15s $version\n", $pkg);
}
}
Modified: branches/upstream/librose-db-object-perl/current/t/as-tree.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/librose-db-object-perl/current/t/as-tree.t?rev=26733&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/t/as-tree.t (original)
+++ branches/upstream/librose-db-object-perl/current/t/as-tree.t Mon Nov 10 09:05:50 2008
@@ -715,7 +715,12 @@
eval { require YAML::Syck };
$Have_YAML = $@ ? 0 : 1;
- eval { require JSON };
+ eval
+ {
+ require JSON;
+ die "JSON $JSON::VERSION too old" unless($JSON::VERSION >= 2.00);
+ };
+
$Have_JSON = $@ ? 0 : 1;
}
Modified: branches/upstream/librose-db-object-perl/current/t/db-object-helpers.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/librose-db-object-perl/current/t/db-object-helpers.t?rev=26733&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/t/db-object-helpers.t (original)
+++ branches/upstream/librose-db-object-perl/current/t/db-object-helpers.t Mon Nov 10 09:05:50 2008
@@ -3,12 +3,13 @@
use strict;
#use Test::LongString;
-use Test::More tests => (87 * 4) + 2;
+use Test::More tests => (90 * 4) + 3;
BEGIN
{
require 't/test-lib.pl';
use_ok('Rose::DB::Object');
+ use_ok('Rose::DB::Object::Manager');
use_ok('Rose::DB::Object::Helpers');
}
@@ -26,7 +27,7 @@
{
SKIP:
{
- skip("$db_type tests", 87) unless($Have{$db_type});
+ skip("$db_type tests", 90) unless($Have{$db_type});
}
next unless($Have{$db_type});
@@ -307,6 +308,29 @@
ok(get_column_value_modified($o, 'age'), "dirty_columns 4 - $db_type");
ok(get_column_value_modified($o, 'name'), "dirty_columns 5 - $db_type");
+
+ # insert_or_update with no key
+
+ Rose::DB::Object::Manager->delete_objects(all => 1, object_class => $other_class);
+ Rose::DB::Object::Manager->delete_objects(all => 1, object_class => $class);
+
+ my $unknown = $class->new(age => 99);
+
+ eval { $unknown->insert_or_update };
+
+ ok(!$@ && $unknown->id =~ /^\d+$/, "insert_or_update() with no key - $db_type");
+
+ # load_or_insert with no key
+
+ $unknown = $class->new(age => 100);
+ eval { $unknown->load_or_insert };
+ ok(!$@ && $unknown->id =~ /^\d+$/, "load_or_insert() with no key - $db_type");
+
+ # load_or_save with no key
+
+ $unknown = $class->new(age => 101);
+ eval { $unknown->load_or_save };
+ ok(!$@ && $unknown->id =~ /^\d+$/, "load_or_save() with no key - $db_type");
}
BEGIN
@@ -376,7 +400,7 @@
CREATE TABLE rose_db_object_test
(
id SERIAL NOT NULL PRIMARY KEY,
- name VARCHAR(255) NOT NULL,
+ name VARCHAR(255),
age INT,
laz VARCHAR(255),
@@ -388,7 +412,7 @@
CREATE TABLE rose_db_object_test_other
(
id SERIAL NOT NULL PRIMARY KEY,
- name VARCHAR(255) NOT NULL,
+ name VARCHAR(255),
rose_db_object_test_id INT REFERENCES rose_db_object_test (id)
)
EOF
@@ -462,7 +486,7 @@
CREATE TABLE rose_db_object_test_other
(
id INT AUTO_INCREMENT PRIMARY KEY,
- name VARCHAR(255) NOT NULL,
+ name VARCHAR(255),
rose_db_object_test_id INT REFERENCES rose_db_object_test (id)
)
EOF
@@ -533,7 +557,7 @@
CREATE TABLE rose_db_object_test
(
id SERIAL NOT NULL PRIMARY KEY,
- name VARCHAR(255) NOT NULL,
+ name VARCHAR(255),
age INT,
laz VARCHAR(255),
@@ -545,7 +569,7 @@
CREATE TABLE rose_db_object_test_other
(
id SERIAL NOT NULL PRIMARY KEY,
- name VARCHAR(255) NOT NULL,
+ name VARCHAR(255),
rose_db_object_test_id INT REFERENCES rose_db_object_test (id)
)
EOF
@@ -605,7 +629,7 @@
CREATE TABLE rose_db_object_test
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
- name VARCHAR(255) NOT NULL,
+ name VARCHAR(255),
age INT,
laz VARCHAR(255),
@@ -617,7 +641,7 @@
CREATE TABLE rose_db_object_test_other
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
- name VARCHAR(255) NOT NULL,
+ name VARCHAR(255),
rose_db_object_test_id INT REFERENCES rose_db_object_test (id)
)
EOF
More information about the Pkg-perl-cvs-commits
mailing list