r38686 - in /trunk/liborlite-perl: Changes MANIFEST META.yml debian/changelog lib/ORLite.pm t/06_create.t t/07_pk.sql t/07_pk.t t/lib/Test.pm
bricas-guest at users.alioth.debian.org
bricas-guest at users.alioth.debian.org
Fri Jun 26 12:52:27 UTC 2009
Author: bricas-guest
Date: Fri Jun 26 12:52:18 2009
New Revision: 38686
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=38686
Log:
New upstream release
Added:
trunk/liborlite-perl/t/07_pk.sql
trunk/liborlite-perl/t/07_pk.t
Modified:
trunk/liborlite-perl/Changes
trunk/liborlite-perl/MANIFEST
trunk/liborlite-perl/META.yml
trunk/liborlite-perl/debian/changelog
trunk/liborlite-perl/lib/ORLite.pm
trunk/liborlite-perl/t/06_create.t
trunk/liborlite-perl/t/lib/Test.pm
Modified: trunk/liborlite-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/Changes?rev=38686&op=diff
==============================================================================
--- trunk/liborlite-perl/Changes (original)
+++ trunk/liborlite-perl/Changes Fri Jun 26 12:52:18 2009
@@ -1,4 +1,9 @@
Changes for Perl extension ORLite
+
+1.23 Thu 11 Jun 2009
+ - Fixed a bug in method ->delete which deleted more than the actual
+ object in case the primary key consist of more than one column.
+ Added basic support for such primary keys with more than one column.
1.22 Mon 1 Jun 2009
- Updated to Module::Install::DSL 0.91
Modified: trunk/liborlite-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/MANIFEST?rev=38686&op=diff
==============================================================================
--- trunk/liborlite-perl/MANIFEST (original)
+++ trunk/liborlite-perl/MANIFEST Fri Jun 26 12:52:18 2009
@@ -23,6 +23,8 @@
t/04_readonly.t
t/05_notables.t
t/06_create.t
+t/07_pk.sql
+t/07_pk.t
t/97_meta.t
t/98_pod.t
t/99_pmv.t
Modified: trunk/liborlite-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/META.yml?rev=38686&op=diff
==============================================================================
--- trunk/liborlite-perl/META.yml (original)
+++ trunk/liborlite-perl/META.yml Fri Jun 26 12:52:18 2009
@@ -32,4 +32,4 @@
ChangeLog: http://fisheye2.atlassian.com/changelog/cpan/trunk/ORLite
license: http://dev.perl.org/licenses/
repository: http://svn.ali.as/cpan/trunk/ORLite
-version: 1.22
+version: 1.23
Modified: trunk/liborlite-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/debian/changelog?rev=38686&op=diff
==============================================================================
--- trunk/liborlite-perl/debian/changelog (original)
+++ trunk/liborlite-perl/debian/changelog Fri Jun 26 12:52:18 2009
@@ -1,8 +1,12 @@
-liborlite-perl (1.22-2) UNRELEASED; urgency=low
+liborlite-perl (1.23-1) UNRELEASED; urgency=low
+ [ Brian Cassidy ]
+ * New upstream release
+
+ [ Nathan Handler ]
* debian/watch: Update to ignore development releases.
- -- Nathan Handler <nhandler at ubuntu.com> Sat, 06 Jun 2009 01:36:48 +0000
+ -- Brian Cassidy <brian.cassidy at gmail.com> Fri, 26 Jun 2009 09:49:56 -0300
liborlite-perl (1.22-1) unstable; urgency=low
Modified: trunk/liborlite-perl/lib/ORLite.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/lib/ORLite.pm?rev=38686&op=diff
==============================================================================
--- trunk/liborlite-perl/lib/ORLite.pm (original)
+++ trunk/liborlite-perl/lib/ORLite.pm Fri Jun 26 12:52:18 2009
@@ -15,7 +15,7 @@
use vars qw{$VERSION};
BEGIN {
- $VERSION = '1.22';
+ $VERSION = '1.23';
}
@@ -235,8 +235,7 @@
$table->{cindex} = map { $_->{name} => $_ } @columns;
# Discover the primary key
- $table->{pk} = List::Util::first { $_->{pk} } @columns;
- $table->{pk} = $table->{pk}->{name} if $table->{pk};
+ @{$table->{pk}} = map($_->{name}, grep { $_->{pk} } @columns);
# What will be the class for this table
$table->{class} = ucfirst lc $table->{name};
@@ -306,6 +305,11 @@
if ( defined $table->{pk} and ! $readonly ) {
my $nattr = join "\n", map { "\t\t$_ => \$attr{$_}," } @names;
my $iattr = join "\n", map { "\t\t\$self->{$_}," } @names;
+ my $fill_pk = scalar @{$table->{pk}} == 1
+ ? "\t\$self->{$table->{pk}->[0]} = \$dbh->func('last_insert_rowid') unless \$self->{$table->{pk}->[0]};"
+ : q{};
+ my $where_pk = join(' and ', map("$_ = ?", @{$table->{pk}}));
+ my $where_pk_attr = join("\n", map("\t\t\$self->{$_},", @{$table->{pk}}));
$code .= <<"END_PERL";
sub new {
@@ -326,15 +330,16 @@
\$dbh->do('$sql->{insert}', {},
$iattr
);
- \$self->{$table->{pk}} = \$dbh->func('last_insert_rowid') unless \$self->{$table->{pk}};
+$fill_pk
return \$self;
}
sub delete {
my \$self = shift;
return $pkg->do(
- 'delete from $table->{name} where $table->{pk} = ?',
- {}, \$self->{$table->{pk}},
+ 'delete from $table->{name} where $where_pk',
+ {},
+$where_pk_attr
) if ref \$self;
Carp::croak("Must use truncate to delete all rows") unless \@_;
return $pkg->do(
@@ -354,7 +359,7 @@
# Generate the accessors
$code .= join "\n\n", map { $_->{fk} ? <<"END_DIRECT" : <<"END_ACCESSOR" } @columns;
sub $_->{name} {
- ($_->{fk}->[1]->{class}\->select('where $_->{fk}->[1]->{pk} = ?', \$_[0]->{$_->{name}}))[0];
+ ($_->{fk}->[1]->{class}\->select('where $_->{fk}->[1]->{pk}->[0] = ?', \$_[0]->{$_->{name}}))[0];
}
END_DIRECT
sub $_->{name} {
Modified: trunk/liborlite-perl/t/06_create.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/t/06_create.t?rev=38686&op=diff
==============================================================================
--- trunk/liborlite-perl/t/06_create.t (original)
+++ trunk/liborlite-perl/t/06_create.t Fri Jun 26 12:52:18 2009
@@ -34,7 +34,7 @@
create => 1,
tables => 0,
append => 'sub append { 2 }',
-}, -DEBUG;
+};
1;
END_PERL
Added: trunk/liborlite-perl/t/07_pk.sql
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/t/07_pk.sql?rev=38686&op=file
==============================================================================
--- trunk/liborlite-perl/t/07_pk.sql (added)
+++ trunk/liborlite-perl/t/07_pk.sql Fri Jun 26 12:52:18 2009
@@ -1,0 +1,17 @@
+create table table_one (
+ col1 integer not null,
+ col2 integer not null,
+ col3 string,
+ primary key ('col1', 'col2')
+);
+
+insert into table_one ( col1, col2, col3 ) values ( 1, 1, 'a' );
+insert into table_one ( col1, col2, col3 ) values ( 1, 2, 'b' );
+insert into table_one ( col1, col2, col3 ) values ( 1, 3, 'c' );
+insert into table_one ( col1, col2, col3 ) values ( 2, 1, 'd' );
+insert into table_one ( col1, col2, col3 ) values ( 2, 2, 'e' );
+insert into table_one ( col1, col2, col3 ) values ( 2, 3, 'f' );
+insert into table_one ( col1, col2, col3 ) values ( 3, 1, 'g' );
+insert into table_one ( col1, col2, col3 ) values ( 3, 2, 'h' );
+insert into table_one ( col1, col2, col3 ) values ( 3, 3, 'i' );
+
Added: trunk/liborlite-perl/t/07_pk.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/t/07_pk.t?rev=38686&op=file
==============================================================================
--- trunk/liborlite-perl/t/07_pk.t (added)
+++ trunk/liborlite-perl/t/07_pk.t Fri Jun 26 12:52:18 2009
@@ -1,0 +1,48 @@
+#!/usr/bin/perl
+
+# Tests relating to primary keys.
+
+BEGIN {
+ $| = 1;
+ $^W = 1;
+}
+
+use Test::More tests => 6;
+use File::Spec::Functions ':ALL';
+use t::lib::Test;
+
+
+#####################################################################
+# Set up for testing
+
+# Connect
+my $file = test_db();
+my $dbh = create_ok(
+ file => catfile(qw{ t 07_pk.sql }),
+ connect => [ "dbi:SQLite:$file" ],
+);
+
+# Create the test package
+eval <<"END_PERL"; die $@ if $@;
+package Foo::Bar;
+
+use strict;
+use ORLite '$file';
+
+1;
+END_PERL
+
+
+#####################################################################
+# Run the tests
+
+my @t1 = Foo::Bar::TableOne->select;
+is( scalar(@t1), 9, 'Got 9 table_one objects' );
+isa_ok( $t1[0], 'Foo::Bar::TableOne' );
+is( $t1[2]->delete(), 1, 'One entry deleted');
+ at t1 = Foo::Bar::TableOne->select('where col1 = ?', 1);
+is( scalar(@t1), 2, 'Got 2 table_one objects' );
+ at t1 = Foo::Bar::TableOne->select('where col1 = ? and col2 = ?', 1, 2);
+is( $t1[0]->col3, 'b', 'Got line with col3 = b');
+
+1;
Modified: trunk/liborlite-perl/t/lib/Test.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liborlite-perl/t/lib/Test.pm?rev=38686&op=diff
==============================================================================
--- trunk/liborlite-perl/t/lib/Test.pm (original)
+++ trunk/liborlite-perl/t/lib/Test.pm Fri Jun 26 12:52:18 2009
@@ -8,7 +8,7 @@
use vars qw{$VERSION @ISA @EXPORT};
BEGIN {
- $VERSION = '1.22';
+ $VERSION = '1.23';
@ISA = 'Exporter';
@EXPORT = qw{ test_db connect_ok create_ok };
}
More information about the Pkg-perl-cvs-commits
mailing list