r26009 - in /branches/upstream/liborlite-perl/current: Changes MANIFEST META.yml README lib/ORLite.pm t/06_create.t t/lib/Test.pm

gwolf at users.alioth.debian.org gwolf at users.alioth.debian.org
Tue Oct 14 04:56:47 UTC 2008


Author: gwolf
Date: Tue Oct 14 04:56:14 2008
New Revision: 26009

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=26009
Log:
[svn-upgrade] Integrating new upstream version, liborlite-perl (0.15)

Added:
    branches/upstream/liborlite-perl/current/t/06_create.t
Modified:
    branches/upstream/liborlite-perl/current/Changes
    branches/upstream/liborlite-perl/current/MANIFEST
    branches/upstream/liborlite-perl/current/META.yml
    branches/upstream/liborlite-perl/current/README
    branches/upstream/liborlite-perl/current/lib/ORLite.pm
    branches/upstream/liborlite-perl/current/t/lib/Test.pm

Modified: branches/upstream/liborlite-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/Changes?rev=26009&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/Changes (original)
+++ branches/upstream/liborlite-perl/current/Changes Tue Oct 14 04:56:14 2008
@@ -1,4 +1,12 @@
 Changes for Perl extension ORLite
+
+0.15 Wed 24 Sep 2008
+	- Adding support for writable pragmas
+	- Adding tests for pragmas, schema_version and user_version
+
+0.14 Tue 23 Sep 2008
+	- Removed the last remnants of %ORLite::DSN and %ORLite::DBH.
+	- Added support for the "create" param to allow database creation
 
 0.13 Fri 19 Sep 2008
 	- Fixed critical bug introduced in 0.10 or somewhere around there,

Modified: branches/upstream/liborlite-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/MANIFEST?rev=26009&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/MANIFEST (original)
+++ branches/upstream/liborlite-perl/current/MANIFEST Tue Oct 14 04:56:14 2008
@@ -21,6 +21,7 @@
 t/03_fk.t
 t/04_readonly.t
 t/05_notables.t
+t/06_create.t
 t/97_meta.t
 t/98_pod.t
 t/99_pmv.t

Modified: branches/upstream/liborlite-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/META.yml?rev=26009&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/META.yml (original)
+++ branches/upstream/liborlite-perl/current/META.yml Tue Oct 14 04:56:14 2008
@@ -25,4 +25,4 @@
   perl: 5.6.0
 resources:
   license: http://dev.perl.org/licenses/
-version: 0.13
+version: 0.15

Modified: branches/upstream/liborlite-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/README?rev=26009&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/README (original)
+++ branches/upstream/liborlite-perl/current/README Tue Oct 14 04:56:14 2008
@@ -228,7 +228,7 @@
 
   pragma
       # Get the user_version for the schema
-      my $version = Foo::Bar->pragma('schema_version');
+      my $version = Foo::Bar->pragma('user_version');
 
     The "pragma" method provides a convenient method for fetching a pragma
     for a datase. See the SQLite documentation for more details.
@@ -241,6 +241,8 @@
 TO DO
     - Support for intuiting reverse relations from foreign keys
 
+    - Document the 'create' and 'table' params
+
 SUPPORT
     Bugs should be reported via the CPAN bug tracker at
 

Modified: branches/upstream/liborlite-perl/current/lib/ORLite.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/lib/ORLite.pm?rev=26009&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/lib/ORLite.pm (original)
+++ branches/upstream/liborlite-perl/current/lib/ORLite.pm Tue Oct 14 04:56:14 2008
@@ -18,11 +18,9 @@
 	require DBD::SQLite;
 }
 
-use vars qw{$VERSION %DSN %DBH};
+use vars qw{$VERSION};
 BEGIN {
-	$VERSION = '0.13';
-	%DSN     = ();
-	%DBH     = ();
+	$VERSION = '0.15';
 }
 
 
@@ -57,11 +55,21 @@
 	} else {
 		Carp::croak("Missing, empty or invalid params HASH");
 	}
-	unless ( defined _STRING($params{file}) and -f $params{file} ) {
-		Carp::croak("Missing or invalid file param");	
+	unless ( defined $params{create} ) {
+		$params{create} = 0;
+	}
+	unless (
+		defined _STRING($params{file})
+		and (
+			$params{create}
+			or
+			-f $params{file}
+		)
+	) {
+		Carp::croak("Missing or invalid file param");
 	}
 	unless ( defined $params{readonly} ) {
-		$params{readonly} = ! -w $params{file};
+		$params{readonly} = $params{create} ? 0 : ! -w $params{file};
 	}
 	unless ( defined $params{tables} ) {
 		$params{tables} = 1;
@@ -77,9 +85,8 @@
 	my $file     = File::Spec->rel2abs($params{file});
 	my $pkg      = $params{package};
 	my $readonly = $params{readonly};
-	$DSN{$pkg}   = "dbi:SQLite:$file";
-	$DBH{$pkg}   = undef;
-	my $dbh      = DBI->connect($DSN{$pkg});
+	my $dsn      = "dbi:SQLite:$file";
+	my $dbh      = DBI->connect($dsn);
 
 	# Check the schema version before generating
 	my $version  = $dbh->selectrow_arrayref('pragma user_version')->[0];
@@ -93,12 +100,9 @@
 
 use strict;
 
-my \$DSN = 'dbi:SQLite:$file';
 my \$DBH = undef;
 
-sub dsn {
-	\$DSN;
-}
+sub dsn { '$dsn' }
 
 sub dbh {
 	\$DBH or
@@ -143,7 +147,8 @@
 }
 
 sub pragma {
-	shift->selectrow_arrayref('pragma ' . shift)->[0];
+	\$_[0]->do("pragma \$_[1] = \$_[2]") if \@_ > 2;
+	\$_[0]->selectrow_arrayref("pragma \$_[1]")->[0];
 }
 
 END_PERL
@@ -178,7 +183,7 @@
 	# Optionally generate the table classes
 	if ( $params{tables} ) {
 		# Capture the raw schema information
-		my $tables   = $dbh->selectall_arrayref(
+		my $tables = $dbh->selectall_arrayref(
 			'select * from sqlite_master where type = ?',
 			{ Slice => {} }, 'table',
 		);
@@ -601,7 +606,7 @@
 =head2 pragma
 
   # Get the user_version for the schema
-  my $version = Foo::Bar->pragma('schema_version');
+  my $version = Foo::Bar->pragma('user_version');
 
 The C<pragma> method provides a convenient method for fetching a pragma
 for a datase. See the SQLite documentation for more details.
@@ -616,6 +621,8 @@
 
 - Support for intuiting reverse relations from foreign keys
 
+- Document the 'create' and 'table' params
+
 =head1 SUPPORT
 
 Bugs should be reported via the CPAN bug tracker at

Added: branches/upstream/liborlite-perl/current/t/06_create.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/t/06_create.t?rev=26009&op=file
==============================================================================
--- branches/upstream/liborlite-perl/current/t/06_create.t (added)
+++ branches/upstream/liborlite-perl/current/t/06_create.t Tue Oct 14 04:56:14 2008
@@ -1,0 +1,44 @@
+#!/usr/bin/perl
+
+# Tests database creation, pragmas and versions
+
+use strict;
+
+BEGIN {
+	$|  = 1;
+	$^W = 1;
+}
+
+use Test::More tests => 8;
+use File::Spec::Functions ':ALL';
+use t::lib::Test;
+
+# Set up the file
+my $file = test_db();
+
+# Create the test package
+eval <<"END_PERL"; die $@ if $@;
+package Foo::Bar;
+
+use strict;
+use ORLite {
+	file   => '$file',
+	create => 1,
+	tables => 0,
+};
+
+1;
+END_PERL
+
+ok( Foo::Bar->can('connect'), 'Created read code'  );
+ok( Foo::Bar->can('begin'),   'Created write code' );
+
+# Test ability to get and set pragmas
+is( Foo::Bar->pragma('schema_version' ), 0, 'schema_version is zero' );
+is( Foo::Bar->pragma('user_version' ), 0, 'user_version is zero' );
+is( Foo::Bar->pragma('user_version', 2 ), 2, 'Set user_version' );
+is( Foo::Bar->pragma('user_version' ), 2, 'Confirm user_version changed' );
+
+# Test that the schema_version is updated as expected
+ok( Foo::Bar->do('create table foo ( bar int )'), 'Created test table' );
+is( Foo::Bar->pragma('schema_version' ), 1, 'schema_version is zero' );

Modified: branches/upstream/liborlite-perl/current/t/lib/Test.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/t/lib/Test.pm?rev=26009&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/t/lib/Test.pm (original)
+++ branches/upstream/liborlite-perl/current/t/lib/Test.pm Tue Oct 14 04:56:14 2008
@@ -8,7 +8,7 @@
 
 use vars qw{$VERSION @ISA @EXPORT};
 BEGIN {
-	$VERSION = '0.13';
+        $VERSION = '0.15';
 	@ISA     = qw{ Exporter };
 	@EXPORT  = qw{ test_db connect_ok create_ok };
 }




More information about the Pkg-perl-cvs-commits mailing list