r33446 - in /branches/upstream/libclass-dbi-sqlite-perl: ./ current/ current/lib/ current/lib/Class/ current/lib/Class/DBI/ current/t/ current/t/lib/
ryan52-guest at users.alioth.debian.org
ryan52-guest at users.alioth.debian.org
Thu Apr 16 03:45:13 UTC 2009
Author: ryan52-guest
Date: Thu Apr 16 03:45:07 2009
New Revision: 33446
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=33446
Log:
[svn-inject] Installing original source of libclass-dbi-sqlite-perl
Added:
branches/upstream/libclass-dbi-sqlite-perl/
branches/upstream/libclass-dbi-sqlite-perl/current/
branches/upstream/libclass-dbi-sqlite-perl/current/Changes
branches/upstream/libclass-dbi-sqlite-perl/current/MANIFEST
branches/upstream/libclass-dbi-sqlite-perl/current/META.yml
branches/upstream/libclass-dbi-sqlite-perl/current/Makefile.PL
branches/upstream/libclass-dbi-sqlite-perl/current/lib/
branches/upstream/libclass-dbi-sqlite-perl/current/lib/Class/
branches/upstream/libclass-dbi-sqlite-perl/current/lib/Class/DBI/
branches/upstream/libclass-dbi-sqlite-perl/current/lib/Class/DBI/SQLite.pm
branches/upstream/libclass-dbi-sqlite-perl/current/t/
branches/upstream/libclass-dbi-sqlite-perl/current/t/00_compile.t
branches/upstream/libclass-dbi-sqlite-perl/current/t/01_sqlite.t
branches/upstream/libclass-dbi-sqlite-perl/current/t/02_table.t
branches/upstream/libclass-dbi-sqlite-perl/current/t/03_multi_pk.t
branches/upstream/libclass-dbi-sqlite-perl/current/t/lib/
branches/upstream/libclass-dbi-sqlite-perl/current/t/lib/Film.pm
Added: branches/upstream/libclass-dbi-sqlite-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-sqlite-perl/current/Changes?rev=33446&op=file
==============================================================================
--- branches/upstream/libclass-dbi-sqlite-perl/current/Changes (added)
+++ branches/upstream/libclass-dbi-sqlite-perl/current/Changes Thu Apr 16 03:45:07 2009
@@ -1,0 +1,47 @@
+Revision history for Perl extension Class::DBI::SQLite
+
+0.11 Thu Oct 6 02:47:28 UTC 2005
+ - Fixed test suite for Windows
+ [cpan #14939]
+
+0.10 Tue Aug 23 21:57:46 UTC 2005
+ - Fixed warnings when there's no PK found
+ (Thanks to William <william at knowmad.com>)
+
+0.09 Sat Apr 16 05:35:45 JST 2005
+ - Fixed some bugs in Multi PK support
+ (Thanks to David Naughton)
+
+0.08 Thu Mar 17 18:17:34 JST 2005
+ - Kiss SQL::Parser goodbye
+ (Markus Ramberg)
+
+0.07 Fri Jan 28 03:02:10 JST 2005
+ - Skip REFERENCES sql clause to bypass SQL::Parser's limitation
+ (Sebastian Riedel)
+
+0.06 Tue Oct 19 16:44:39 JST 2004
+ - Removed debugging statement from the code.
+
+0.05 Tue Oct 19 16:44:39 JST 2004
+ - Fixed error in PRAGMA table_info(?) with newer DBD::SQLite
+ http://rt.cpan.org/NoAuth/Bug.html?id=7794
+ Thanks to Seth Gordon and Marcus Ramberg
+
+0.04 Mon Mar 15 20:56:38 JST 2004
+ - Added t/02_table.t in MANIFEST
+ (Thanks to Tony Bowden)
+ - Added SQL::Dialects::AnyData to PREREQ_PM
+
+0.03 Thu Feb 5 03:38:20 JST 2004
+ * Fixed bug that SQL::Parser barfs with TIMESTAMP column
+ (Thanks to Aaron Straup Cope)
+ - Fixed test failure that columns() no longer preserves its order.
+
+0.02 Fri Aug 9 15:59:44 JST 2002
+ - Added tests to see commit() really works (needs Ima::DBI >= 0.27)
+ * Added set_up_table() method
+ (Thanks to Tomohiro Ikebe <ikebe at cpan.org>)
+
+0.01 Sat Feb 23 22:49:15 2002
+ - original version
Added: branches/upstream/libclass-dbi-sqlite-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-sqlite-perl/current/MANIFEST?rev=33446&op=file
==============================================================================
--- branches/upstream/libclass-dbi-sqlite-perl/current/MANIFEST (added)
+++ branches/upstream/libclass-dbi-sqlite-perl/current/MANIFEST Thu Apr 16 03:45:07 2009
@@ -1,0 +1,10 @@
+Changes
+lib/Class/DBI/SQLite.pm
+Makefile.PL
+MANIFEST This list of files
+t/00_compile.t
+t/01_sqlite.t
+t/02_table.t
+t/03_multi_pk.t
+t/lib/Film.pm
+META.yml Module meta-data (added by MakeMaker)
Added: branches/upstream/libclass-dbi-sqlite-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-sqlite-perl/current/META.yml?rev=33446&op=file
==============================================================================
--- branches/upstream/libclass-dbi-sqlite-perl/current/META.yml (added)
+++ branches/upstream/libclass-dbi-sqlite-perl/current/META.yml Thu Apr 16 03:45:07 2009
@@ -1,0 +1,14 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Class-DBI-SQLite
+version: 0.11
+version_from: lib/Class/DBI/SQLite.pm
+installdirs: site
+requires:
+ Class::DBI: 0.85
+ DBD::SQLite: 0.07
+ Ima::DBI: 0.27
+ Test::More: 0.32
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.27
Added: branches/upstream/libclass-dbi-sqlite-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-sqlite-perl/current/Makefile.PL?rev=33446&op=file
==============================================================================
--- branches/upstream/libclass-dbi-sqlite-perl/current/Makefile.PL (added)
+++ branches/upstream/libclass-dbi-sqlite-perl/current/Makefile.PL Thu Apr 16 03:45:07 2009
@@ -1,0 +1,11 @@
+use ExtUtils::MakeMaker;
+WriteMakefile(
+ 'NAME' => 'Class::DBI::SQLite',
+ 'VERSION_FROM' => 'lib/Class/DBI/SQLite.pm', # finds $VERSION
+ 'PREREQ_PM' => {
+ 'Test::More' => 0.32,
+ 'Class::DBI' => 0.85,
+ 'Ima::DBI' => 0.27,
+ 'DBD::SQLite' => 0.07,
+ },
+);
Added: branches/upstream/libclass-dbi-sqlite-perl/current/lib/Class/DBI/SQLite.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-sqlite-perl/current/lib/Class/DBI/SQLite.pm?rev=33446&op=file
==============================================================================
--- branches/upstream/libclass-dbi-sqlite-perl/current/lib/Class/DBI/SQLite.pm (added)
+++ branches/upstream/libclass-dbi-sqlite-perl/current/lib/Class/DBI/SQLite.pm Thu Apr 16 03:45:07 2009
@@ -1,0 +1,95 @@
+package Class::DBI::SQLite;
+
+use strict;
+use vars qw($VERSION);
+$VERSION = "0.11";
+
+require Class::DBI;
+use base qw(Class::DBI);
+
+sub _auto_increment_value {
+ my $self = shift;
+ return $self->db_Main->func("last_insert_rowid");
+}
+
+sub set_up_table {
+ my($class, $table) = @_;
+
+ # find all columns.
+ my $sth = $class->db_Main->prepare("PRAGMA table_info('$table')");
+ $sth->execute();
+ my @columns;
+ while (my $row = $sth->fetchrow_hashref) {
+ push @columns, $row->{name};
+ }
+ $sth->finish;
+
+ # find primary key. so complex ;-(
+ $sth = $class->db_Main->prepare(<<'SQL');
+SELECT sql FROM sqlite_master WHERE tbl_name = ?
+SQL
+ $sth->execute($table);
+ my($sql) = $sth->fetchrow_array;
+ $sth->finish;
+ my ($primary) = $sql =~ m/
+ (?:\(|\,) # either a ( to start the definition or a , for next
+ \s* # maybe some whitespace
+ (\w+) # the col name
+ [^,]* # anything but the end or a ',' for next column
+ PRIMARY\sKEY/sxi;
+ my @pks;
+ if ($primary) {
+ @pks = ($primary);
+ } else {
+ my ($pks)= $sql =~ m/PRIMARY\s+KEY\s*\(\s*([^)]+)\s*\)/;
+ @pks = split(m/\s*\,\s*/, $pks) if $pks;
+ }
+ $class->table($table);
+ $class->columns(Primary => @pks);
+ $class->columns(All => @columns);
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Class::DBI::SQLite - Extension to Class::DBI for sqlite
+
+=head1 SYNOPSIS
+
+ package Film;
+ use base qw(Class::DBI::SQLite);
+ __PACKAGE__->set_db('Main', 'dbi:SQLite:dbname=dbfile', '', '');
+ __PACKAGE__->set_up_table('Movies');
+
+ package main;
+ my $film = Film->create({
+ name => 'Bad Taste',
+ title => 'Peter Jackson',
+ });
+ my $id = $film->id; # auto-incremented
+
+=head1 DESCRIPTION
+
+Class::DBI::SQLite is an extension to Class::DBI for DBD::SQLite.
+It allows you to populate an auto-incremented row id after insert.
+
+The C<set_up_table> method automates the setup of columns and
+primary key(s) via the SQLite PRAGMA statement.
+
+=head1 AUTHOR
+
+Tatsuhiko Miyagawa E<lt>miyagawa at bulknews.netE<gt>
+
+C<set_up_table> implementation by Tomohiro Ikebe E<lt>ikebe at cpan.orgE<gt>
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+L<Class::DBI>, L<DBD::SQLite>
+
+=cut
Added: branches/upstream/libclass-dbi-sqlite-perl/current/t/00_compile.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-sqlite-perl/current/t/00_compile.t?rev=33446&op=file
==============================================================================
--- branches/upstream/libclass-dbi-sqlite-perl/current/t/00_compile.t (added)
+++ branches/upstream/libclass-dbi-sqlite-perl/current/t/00_compile.t Thu Apr 16 03:45:07 2009
@@ -1,0 +1,4 @@
+use strict;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'Class::DBI::SQLite' }
Added: branches/upstream/libclass-dbi-sqlite-perl/current/t/01_sqlite.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-sqlite-perl/current/t/01_sqlite.t?rev=33446&op=file
==============================================================================
--- branches/upstream/libclass-dbi-sqlite-perl/current/t/01_sqlite.t (added)
+++ branches/upstream/libclass-dbi-sqlite-perl/current/t/01_sqlite.t Thu Apr 16 03:45:07 2009
@@ -1,0 +1,30 @@
+use strict;
+use Test::More tests => 42;
+use lib 't/lib';
+
+use Class::DBI::SQLite;
+
+use Film;
+Film->CONSTRUCT;
+
+for my $i (1..10) {
+ my $film = Film->create({
+ title => "movie-$i",
+ director => "director-$i",
+ });
+ isa_ok $film, 'Film';
+ like $film->id, qr/\d+/, "id is " . $film->id;
+ is $film->title, "movie-$i";
+ is $film->director, "director-$i";
+}
+
+Film->dbi_commit;
+Film->db_Main->disconnect;
+
+my @movies = Film->retrieve_all;
+is @movies, 10, '10 movies out there';
+
+my %seen;
+my @uniq = grep { !$seen{$_}++ } map $_->id, @movies;
+is @uniq, 10, "10 unique ids - @uniq";
+
Added: branches/upstream/libclass-dbi-sqlite-perl/current/t/02_table.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-sqlite-perl/current/t/02_table.t?rev=33446&op=file
==============================================================================
--- branches/upstream/libclass-dbi-sqlite-perl/current/t/02_table.t (added)
+++ branches/upstream/libclass-dbi-sqlite-perl/current/t/02_table.t Thu Apr 16 03:45:07 2009
@@ -1,0 +1,51 @@
+use strict;
+use Test::More tests => 5;
+
+use Class::DBI::SQLite;
+use DBI;
+
+unlink './t/table.db' if -e './t/table.db';
+
+my $dbh = DBI->connect(
+ 'dbi:SQLite:dbname=./t/table.db', '', '',
+ {
+ RaiseError => 1,
+ PrintError => 1,
+ AutoCommit => 1
+ }
+);
+
+$dbh->do('CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, foo INTEGER, bar TEXT)');
+
+package Foo;
+use base qw(Class::DBI::SQLite);
+
+__PACKAGE__->set_db(Main => 'dbi:SQLite:dbname=./t/table.db', '', '');
+__PACKAGE__->set_up_table('foo');
+
+package main;
+
+is(Foo->table, 'foo');
+is(Foo->columns, 3);
+my @columns = sort Foo->columns('All');
+is_deeply(\@columns, [sort qw(id foo bar)]);
+
+for my $i(1 .. 10) {
+ Foo->create({
+ foo => $i,
+ bar => 'bar'. $i
+ });
+}
+
+my $obj = Foo->retrieve(3);
+is($obj->bar, 'bar3');
+
+my $new_obj = Foo->create({
+ foo => 100,
+ bar => 'barbar'
+});
+is($new_obj->id, 11);
+
+END {
+ unlink './t/table.db';
+}
Added: branches/upstream/libclass-dbi-sqlite-perl/current/t/03_multi_pk.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-sqlite-perl/current/t/03_multi_pk.t?rev=33446&op=file
==============================================================================
--- branches/upstream/libclass-dbi-sqlite-perl/current/t/03_multi_pk.t (added)
+++ branches/upstream/libclass-dbi-sqlite-perl/current/t/03_multi_pk.t Thu Apr 16 03:45:07 2009
@@ -1,0 +1,45 @@
+use strict;
+use Test::More tests => 2;
+
+use Class::DBI::SQLite;
+use DBI;
+use Carp qw( confess );
+
+unlink './t/multi_pk.db' if -e './t/multi_pk.db';
+
+my $dbh = DBI->connect(
+ 'dbi:SQLite:dbname=./t/multi_pk.db', '', '',
+ {
+ RaiseError => 1,
+ PrintError => 1,
+ AutoCommit => 1
+ }
+);
+
+$dbh->do('CREATE TABLE multi_pk (revision INTEGER, version INTEGER, msg TEXT, PRIMARY KEY (revision,version) )');
+
+package MultiPK;
+use base qw(Class::DBI::SQLite);
+
+__PACKAGE__->connection('dbi:SQLite:dbname=./t/multi_pk.db', '', '');
+__PACKAGE__->set_up_table('multi_pk');
+
+package main;
+
+my @pks = sort MultiPK->primary_columns;
+is_deeply( \@pks, [qw(revision version)] );
+
+for (1..10) {
+ MultiPK->create({
+ revision => $_,
+ version => $_,
+ msg => "version $_",
+ });
+}
+
+my $obj = MultiPK->retrieve( revision => 3, version => 3 );
+is($obj->msg, 'version 3');
+
+END {
+ unlink './t/multi_pk.db';
+}
Added: branches/upstream/libclass-dbi-sqlite-perl/current/t/lib/Film.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-sqlite-perl/current/t/lib/Film.pm?rev=33446&op=file
==============================================================================
--- branches/upstream/libclass-dbi-sqlite-perl/current/t/lib/Film.pm (added)
+++ branches/upstream/libclass-dbi-sqlite-perl/current/t/lib/Film.pm Thu Apr 16 03:45:07 2009
@@ -1,0 +1,27 @@
+package Film;
+use strict;
+
+use File::Temp qw(tempdir tempfile);
+
+use base qw(Class::DBI::SQLite);
+BEGIN {
+ my $dir = tempdir( CLEANUP => 1 );
+ my($fh, $filename) = tempfile( DIR => $dir );
+ __PACKAGE__->set_db('Main', "dbi:SQLite:dbname=$filename", '', '', { AutoCommit => 0 });
+}
+
+__PACKAGE__->table('Movies');
+__PACKAGE__->columns(Primary => qw(id));
+__PACKAGE__->columns(All => qw(id title director));
+
+sub CONSTRUCT {
+ my $class = shift;
+ $class->db_Main->do(<<'SQL');
+CREATE TABLE Movies (
+ id INTEGER NOT NULL PRIMARY KEY,
+ title VARCHAR(32) NOT NULL,
+ director VARCHAR(64) NOT NULL
+)
+SQL
+ ;
+}
More information about the Pkg-perl-cvs-commits
mailing list