r47793 - in /trunk/libcoat-persistent-perl: .gitignore CHANGES MANIFEST Makefile.PL Makefile.old debian/changelog lib/Coat/Persistent.pm lib/Coat/Persistent/Types.pm t/test-database/001_auto_increment.t
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Thu Nov 26 16:24:42 UTC 2009
Author: jawnsy-guest
Date: Thu Nov 26 16:24:37 2009
New Revision: 47793
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=47793
Log:
integrate new upstream release
Added:
trunk/libcoat-persistent-perl/MANIFEST
- copied unchanged from r47776, branches/upstream/libcoat-persistent-perl/current/MANIFEST
Removed:
trunk/libcoat-persistent-perl/Makefile.old
Modified:
trunk/libcoat-persistent-perl/.gitignore
trunk/libcoat-persistent-perl/CHANGES
trunk/libcoat-persistent-perl/Makefile.PL
trunk/libcoat-persistent-perl/debian/changelog
trunk/libcoat-persistent-perl/lib/Coat/Persistent.pm
trunk/libcoat-persistent-perl/lib/Coat/Persistent/Types.pm
trunk/libcoat-persistent-perl/t/test-database/001_auto_increment.t
Modified: trunk/libcoat-persistent-perl/.gitignore
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcoat-persistent-perl/.gitignore?rev=47793&op=diff
==============================================================================
--- trunk/libcoat-persistent-perl/.gitignore (original)
+++ trunk/libcoat-persistent-perl/.gitignore Thu Nov 26 16:24:37 2009
@@ -1,3 +1,5 @@
+Makefile.old
Makefile
pm_to_blib
+t/sqlite/db.sqlite
blib
Modified: trunk/libcoat-persistent-perl/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcoat-persistent-perl/CHANGES?rev=47793&op=diff
==============================================================================
--- trunk/libcoat-persistent-perl/CHANGES (original)
+++ trunk/libcoat-persistent-perl/CHANGES Thu Nov 26 16:24:37 2009
@@ -1,3 +1,6 @@
+2009-11-25 - 0.222 Alexis Sukrieh
+ * support for DBD::CSV >= 0.22
+
2009-07-10 - 0.220 - Alexis Sukrieh
* Add support for undefined primary_keys (bug #47772)
* Now possible to bypass DBIx::Sequence (bug #47773)
Modified: trunk/libcoat-persistent-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcoat-persistent-perl/Makefile.PL?rev=47793&op=diff
==============================================================================
--- trunk/libcoat-persistent-perl/Makefile.PL (original)
+++ trunk/libcoat-persistent-perl/Makefile.PL Thu Nov 26 16:24:37 2009
@@ -16,6 +16,7 @@
'DBD::CSV' => '0', # needed for the test suite
'SQL::Abstract' => '0',
'List::Compare' => '0',
+ 'Test::Database' => '0',
},
test => {TESTS => join( ' ', (glob( 't/*.t'), glob('t/*/*.t')))},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
Modified: trunk/libcoat-persistent-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcoat-persistent-perl/debian/changelog?rev=47793&op=diff
==============================================================================
--- trunk/libcoat-persistent-perl/debian/changelog (original)
+++ trunk/libcoat-persistent-perl/debian/changelog Thu Nov 26 16:24:37 2009
@@ -1,4 +1,4 @@
-libcoat-persistent-perl (0.221-1) UNRELEASED; urgency=low
+libcoat-persistent-perl (0.223-1) UNRELEASED; urgency=low
NOTE: need to fix FTBFS still
@@ -9,7 +9,7 @@
* Standards-Version 3.8.3 (no changes)
* Refreshed patches
- -- Jonathan Yu <jawnsy at cpan.org> Tue, 22 Sep 2009 06:41:51 -0400
+ -- Jonathan Yu <jawnsy at cpan.org> Wed, 25 Nov 2009 19:49:32 -0500
libcoat-persistent-perl (0.210-1) unstable; urgency=low
Modified: trunk/libcoat-persistent-perl/lib/Coat/Persistent.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcoat-persistent-perl/lib/Coat/Persistent.pm?rev=47793&op=diff
==============================================================================
--- trunk/libcoat-persistent-perl/lib/Coat/Persistent.pm (original)
+++ trunk/libcoat-persistent-perl/lib/Coat/Persistent.pm Thu Nov 26 16:24:37 2009
@@ -27,7 +27,7 @@
use vars qw($VERSION @EXPORT $AUTHORITY);
use base qw(Exporter);
-$VERSION = '0.221';
+$VERSION = '0.223';
$AUTHORITY = 'cpan:SUKRIA';
@EXPORT = qw(has_p has_one has_many);
@@ -54,6 +54,7 @@
$MAPPINGS->{'!cache'}{'!default'} ||
undef;
}
+
# The internel sequence engine (DBIx::Sequence)
# If disabled, nothing will be done for the primary keys, their values
@@ -128,20 +129,23 @@
sub map_to_dbi {
my ( $class, $driver, @options ) = @_;
confess "Static method cannot be called from instance" if ref $class;
+ my $connect_options = { PrintError => 0, RaiseError => 0 };
# if map_to_dbi is called from Coat::Persistent, this is the default dbh
$class = '!default' if $class eq 'Coat::Persistent';
my $drivers = Coat::Persistent->drivers;
+
confess "No such driver : $driver, please register the driver first with add_driver()"
unless exists $drivers->{$driver};
# the csv driver needs to load the appropriate DBD module
if ($driver eq 'csv') {
- eval "use DBD::CSV";
+ eval "use DBD::CSV 0.22";
confess "Unable to load DBD::CSV : $@" if $@;
DBD::CSV->import;
+ $connect_options->{csv_null} = 1; # since version 0.25 we have to do that to preserve undef values
}
$MAPPINGS->{'!driver'}{$class} = $driver;
@@ -149,7 +153,7 @@
my ( $table, $user, $pass ) = @options;
$driver = $drivers->{$driver};
$MAPPINGS->{'!dbh'}{$class} =
- DBI->connect( "${driver}:${table}", $user, $pass, { PrintError => 0, RaiseError => 0 });
+ DBI->connect( "${driver}:${table}", $user, $pass, $connect_options);
confess "Can't connect to database ${DBI::err} : ${DBI::errstr}"
unless $MAPPINGS->{'!dbh'}{$class};
@@ -231,6 +235,7 @@
# find_or_create_by_
my $sub_find_or_create = sub {
+
# if 2 args : we're given the value of $attr only
if (@_ == 2) {
my ($class, $value) = @_;
@@ -301,7 +306,7 @@
my $attr_name = (defined $options{class_name}) ? $name : $owned_table_name ;
# record the foreign key
- my $foreign_key = $owned_table_name . '_' . $owned_primary_key;
+ my $foreign_key = $options{foreign_key} || ($owned_table_name . '_' . $owned_primary_key);
has_p $foreign_key => ( isa => 'Int', '!caller' => $class );
my $symbol = "${class}::${attr_name}";
@@ -509,7 +514,6 @@
sub find_by_sql {
my ( $class, $sql, @values ) = @_;
my @objects;
-# warn "find_by_sql\n\tsql: $sql\n\tval: @values\n";
# if cached, try to returned a cached value
if (defined $class->cache) {
@@ -538,7 +542,9 @@
# create the object with attributes, and set virtual ones
foreach my $r (@$rows) {
- my $obj = $class->new(map { ($_ => $r->{$_}) } @given_attr);
+ my %attributes = map { ($_ => $r->{$_}) } @given_attr;
+
+ my $obj = $class->new(%attributes);
$obj->init_on_find();
foreach my $field (@virtual_attr) {
$obj->{$field} = $r->{$field};
@@ -626,6 +632,7 @@
# Class->create([ { foo => 'x' }, {...}, ... ]); # multiple creation
sub create {
# if only two args, we should have an ARRAY containing HASH
+
if (@_ == 2) {
my ($class, $values) = @_;
confess "create received only two args but no ARRAY"
@@ -678,6 +685,9 @@
# a hash containing attr/value pairs for the current object
my %values = map { $_ => $self->get_storage_value_for($_) } @fields;
+# foreach my $k (keys %values) {
+# delete $values{$k} if not defined $values{$k};
+# }
# if not a new object, we have to update
if ( $self->_db_state == CP_ENTRY_EXISTS ) {
@@ -719,6 +729,8 @@
$table_name, { %values, $primary_key => $self->$primary_key });
}
else {
+ map { delete $values{$_} unless defined $values{$_} } keys %values;
+ #warn "values: ".join(", ", keys(%values));
($sql, @values) = $sql_abstract->insert($table_name, \%values);
}
Modified: trunk/libcoat-persistent-perl/lib/Coat/Persistent/Types.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcoat-persistent-perl/lib/Coat/Persistent/Types.pm?rev=47793&op=diff
==============================================================================
--- trunk/libcoat-persistent-perl/lib/Coat/Persistent/Types.pm (original)
+++ trunk/libcoat-persistent-perl/lib/Coat/Persistent/Types.pm Thu Nov 26 16:24:37 2009
@@ -16,6 +16,14 @@
coerce 'Class::Date'
=> from 'UnixTimestamp'
+ => via { Class::Date->new($_) };
+
+coerce 'Class::Date'
+ => from 'Date'
+ => via { Class::Date->new($_) };
+
+coerce 'Class::Date'
+ => from 'DateTime'
=> via { Class::Date->new($_) };
subtype 'DateTime'
Modified: trunk/libcoat-persistent-perl/t/test-database/001_auto_increment.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcoat-persistent-perl/t/test-database/001_auto_increment.t?rev=47793&op=diff
==============================================================================
--- trunk/libcoat-persistent-perl/t/test-database/001_auto_increment.t (original)
+++ trunk/libcoat-persistent-perl/t/test-database/001_auto_increment.t Thu Nov 26 16:24:37 2009
@@ -1,5 +1,5 @@
# This test is here to validate that C::P works without DBIx::Sequence
-use Test::More tests => 10;
+use Test::More;
{
package Book;
@@ -23,65 +23,66 @@
}
my $dbh;
-SKIP: {
- # init
- eval "use Test::Database";
- skip "Test::Database is needed", 5 if $@;
- Test::Database->import;
-
- # MySQL tests
- my ($mysql) = Test::Database->handles( 'mysql' );
- skip "No MySQL database handle available", 5 unless defined $mysql;
- $dbh = $mysql->dbh;
- Coat::Persistent->disable_internal_sequence_engine();
- Coat::Persistent->set_dbh(mysql => $dbh);
-
- eval { $dbh->do("CREATE TABLE books (
- id int(11) not null auto_increment,
- name varchar(30) not null default '',
- created_at datetime not null,
- primary key (id)
- )") };
+# init
+eval "use Test::Database";
+plan skip_all => "Test::Database is needed" if $@;
- my $b = Book->new(name => 'Ubik');
- ok($b->save, 'save works');
- is(1, $b->id, 'first object inserted got id 1');
- ok($b->created_at, 'field created_at is set');
- ok($b->created_at->epoch, 'created_at is a Class::Date object: '.$b->created_at->epoch);
+# MySQL tests
+my ($mysql) = Test::Database->handles( 'mysql' );
+plan skip_all => "No MySQL database handle available"
+ unless defined $mysql;
- my $c = Book->create(name => 'Blade Runner');
- is(2, $c->id, 'second object inserted got id 2');
+plan tests => 10;
+$dbh = $mysql->dbh;
+Coat::Persistent->disable_internal_sequence_engine();
+Coat::Persistent->set_dbh(mysql => $dbh);
- $dbh->do('DROP TABLE books');
+eval { $dbh->do("CREATE TABLE books (
+ id int(11) not null auto_increment,
+ name varchar(30) not null default '',
+ created_at datetime not null,
+ primary key (id)
+)") };
- # SQLite tests
- my ($sqlite) = Test::Database->handles( 'SQLite' );
- skip "No SQLite database handle available", 5 unless defined $sqlite;
+my $b = Book->new(name => 'Ubik');
+ok($b->save, 'save works');
+is(1, $b->id, 'first object inserted got id 1');
+ok($b->created_at, 'field created_at is set');
+ok($b->created_at->epoch, 'created_at is a Class::Date object: '.$b->created_at->epoch);
- $dbh = $sqlite->dbh;
- Coat::Persistent->disable_internal_sequence_engine();
- Coat::Persistent->set_dbh(sqlite => $dbh);
+my $c = Book->create(name => 'Blade Runner');
+is(2, $c->id, 'second object inserted got id 2');
- # Fixtures
- eval { $dbh->do("CREATE TABLE books (
- id INTEGER PRIMARY KEY,
- name varchar(30) ,
- created_at TIMESTAMP
- )") };
+$dbh->do('DROP TABLE books');
- # tests
- $b = Book->new(name => 'Ubik');
- ok($b->save, 'save works');
- is(1, $b->id, 'first object inserted got id 1');
- ok($b->created_at, 'field created_at is set');
- ok($b->created_at->epoch, 'created_at is a Class::Date object: '.$b->created_at->epoch);
+# SQLite tests
- $c = Book->create(name => 'Blade Runner');
- is(2, $c->id, 'second object inserted got id 2');
+my ($sqlite) = Test::Database->handles( 'SQLite' );
+skip "No SQLite database handle available", 5 unless defined $sqlite;
- # cleanup
- $dbh->do('DROP TABLE books');
-};
+$dbh = $sqlite->dbh;
+Coat::Persistent->disable_internal_sequence_engine();
+Coat::Persistent->set_dbh(sqlite => $dbh);
+
+# Fixtures
+eval { $dbh->do("CREATE TABLE books (
+ id INTEGER PRIMARY KEY,
+ name varchar(30) ,
+ created_at TIMESTAMP
+)") };
+
+# tests
+$b = Book->new(name => 'Ubik');
+ok($b->save, 'save works');
+is(1, $b->id, 'first object inserted got id 1');
+ok($b->created_at, 'field created_at is set');
+ok($b->created_at->epoch, 'created_at is a Class::Date object: '.$b->created_at->epoch);
+
+$c = Book->create(name => 'Blade Runner');
+is(2, $c->id, 'second object inserted got id 2');
+
+# cleanup
+$dbh->do('DROP TABLE books');
More information about the Pkg-perl-cvs-commits
mailing list