[Bast-commits] r4497 - in DBIx-Class-ResultSet-HashRef/1.000/trunk: . lib lib/DBIx lib/DBIx/Class lib/DBIx/Class/ResultSet t t/lib t/lib/TestSchema

plu at dev.catalyst.perl.org plu at dev.catalyst.perl.org
Sat Jun 14 15:03:06 BST 2008


Author: plu
Date: 2008-06-14 15:03:05 +0100 (Sat, 14 Jun 2008)
New Revision: 4497

Added:
   DBIx-Class-ResultSet-HashRef/1.000/trunk/Changes
   DBIx-Class-ResultSet-HashRef/1.000/trunk/MANIFEST
   DBIx-Class-ResultSet-HashRef/1.000/trunk/META.yml
   DBIx-Class-ResultSet-HashRef/1.000/trunk/Makefile.PL
   DBIx-Class-ResultSet-HashRef/1.000/trunk/README
   DBIx-Class-ResultSet-HashRef/1.000/trunk/lib/
   DBIx-Class-ResultSet-HashRef/1.000/trunk/lib/DBIx/
   DBIx-Class-ResultSet-HashRef/1.000/trunk/lib/DBIx/Class/
   DBIx-Class-ResultSet-HashRef/1.000/trunk/lib/DBIx/Class/ResultSet/
   DBIx-Class-ResultSet-HashRef/1.000/trunk/lib/DBIx/Class/ResultSet/HashRef.pm
   DBIx-Class-ResultSet-HashRef/1.000/trunk/t/
   DBIx-Class-ResultSet-HashRef/1.000/trunk/t/00-use.t
   DBIx-Class-ResultSet-HashRef/1.000/trunk/t/10-hashref.t
   DBIx-Class-ResultSet-HashRef/1.000/trunk/t/98-pod_coverage.t
   DBIx-Class-ResultSet-HashRef/1.000/trunk/t/99-pod.t
   DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/
   DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema.pm
   DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/
   DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/Role.pm
   DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/User.pm
   DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/UserRole.pm
Log:
added 1.000


Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/Changes
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/Changes	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/Changes	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,5 @@
+Revision history for DBIx-Class-ResultSet-HashRef
+
+0.01  Sat Jun 14 2008
+       Initial release.
+

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/MANIFEST
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/MANIFEST	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/MANIFEST	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,25 @@
+Changes
+inc/Module/AutoInstall.pm
+inc/Module/Install/AutoInstall.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Include.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
+inc/Module/Install.pm
+lib/DBIx/Class/ResultSet/HashRef.pm
+Makefile.PL
+MANIFEST
+META.yml
+README
+t/00-use.t
+t/10-hashref.t
+t/98-pod_coverage.t
+t/99-pod.t
+t/lib/TestSchema.pm
+t/lib/TestSchema/Role.pm
+t/lib/TestSchema/User.pm
+t/lib/TestSchema/UserRole.pm
\ No newline at end of file

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/META.yml
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/META.yml	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/META.yml	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,22 @@
+--- 
+abstract: Adds syntatic sugar to skip the fancy objects
+author: 
+  - Johannes Plunien <plu at cpan.org>
+build_requires: 
+  File::Temp: 0
+  Test::More: 0
+distribution_type: module
+generated_by: Module::Install version 0.68
+license: perl
+meta-spec: 
+  url: http://module-build.sourceforge.net/META-spec-v1.3.html
+  version: 1.3
+name: DBIx-Class-ResultSet-HashRef
+no_index: 
+  directory: 
+    - inc
+    - t
+requires: 
+  DBIx::Class: 0
+  perl: 5.6.1
+version: 1.000

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/Makefile.PL
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/Makefile.PL	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/Makefile.PL	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,18 @@
+use inc::Module::Install 0.67;
+
+if ( -e 'MANIFEST.SKIP' ) {
+    system( 'pod2text lib/DBIx/Class/ResultSet/HashRef.pm > README' );
+}
+
+perl_version '5.006001';
+
+name 'DBIx-Class-ResultSet-HashRef';
+all_from 'lib/DBIx/Class/ResultSet/HashRef.pm';
+
+requires 'DBIx::Class';
+
+test_requires 'Test::More';
+test_requires 'File::Temp';
+
+auto_install;
+WriteAll;

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/README
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/README	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/README	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,67 @@
+NAME
+    DBIx::Class::ResultSet::HashRef - Adds syntatic sugar to skip the fancy
+    objects
+
+SYNOPSIS
+        # in your resultsource class
+        __PACKAGE__->resultset_class( 'DBIx::Class::ResultSet::HashRef' );
+    
+        # in your calling code
+        my $rs = $schema->resultset('User')->search( { } )->hashref_rs;
+        while (my $row = $rs->next) {
+            print Dumper $row;
+        }
+    
+        You can chain up every L<DBIx::Class::ResultSet> method to ->hashref_rs:
+    
+        * ->hashref_rs->all (same as ->hashref_array)
+
+        * ->hashref_rs->first (same as ->hashref_first)
+    
+DESCRIPTION
+    This is a simple way to allow you to set result_class to
+    DBIx::Class::ResultClass::HashRefInflator to skip the fancy objects.
+
+INSTALLATION
+        perl Makefile.PL
+        make
+        make test
+        make install
+
+METHODS
+  hashref_rs( )
+    Sets result_class to DBIx::Class::ResultClass::HashRefInflator and
+    returns the resultset.
+
+  hashref_array( )
+    Calls ->hashref_rs->all and returns depending on the calling context an
+    array or an reference to an array.
+
+        my $rs = $schema->resultset('User')->search( { } )->hashref_array;
+        print Dumper $rs;
+
+        my @rs = $schema->resultset('User')->search( { } )->hashref_array;
+        print Dumper @rs;
+
+  hashref_first( )
+    Returns the first row of the resultset inflated by
+    DBIx::Class::ResultClass::HashRefInflator.
+
+        my $first_row = $schema->resultset('User')->search( { } )->hashref_first;
+        print Dumper $first_row
+
+AUTHOR
+    Johannes Plunien <plu at cpan.org>
+
+COPYRIGHT AND LICENSE
+    Copyright 2008 by Johannes Plunien
+
+    This library is free software; you can redistribute it and/or modify it
+    under the same terms as Perl itself.
+
+    Thanks to mst for his patience.
+
+SEE ALSO
+    * DBIx::Class
+    * DBIx::Class::ResultClass::HashRefInflator
+

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/lib/DBIx/Class/ResultSet/HashRef.pm
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/lib/DBIx/Class/ResultSet/HashRef.pm	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/lib/DBIx/Class/ResultSet/HashRef.pm	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,111 @@
+package DBIx::Class::ResultSet::HashRef;
+
+use warnings;
+use strict;
+use base qw( DBIx::Class::ResultSet );
+use DBIx::Class::ResultClass::HashRefInflator;
+
+our $VERSION = '1.000';
+
+=head1 NAME
+
+DBIx::Class::ResultSet::HashRef - Adds syntatic sugar to skip the fancy objects
+
+=head1 SYNOPSIS
+
+    # in your resultsource class
+    __PACKAGE__->resultset_class( 'DBIx::Class::ResultSet::HashRef' );
+    
+    # in your calling code
+    my $rs = $schema->resultset('User')->search( { } )->hashref_rs;
+    while (my $row = $rs->next) {
+        print Dumper $row;
+    }
+    
+    You can chain up every L<DBIx::Class::ResultSet> method to ->hashref_rs:
+    
+    * ->hashref_rs->all (same as ->hashref_array)
+
+    * ->hashref_rs->first (same as ->hashref_first)
+    
+=head1 DESCRIPTION
+
+This is a simple way to allow you to set result_class to L<DBIx::Class::ResultClass::HashRefInflator> to
+skip the fancy objects.
+
+=head1 INSTALLATION
+
+    perl Makefile.PL
+    make
+    make test
+    make install
+
+=head1 METHODS
+
+=head2 hashref_rs( )
+
+Sets result_class to L<DBIx::Class::ResultClass::HashRefInflator> and returns the resultset.
+
+=cut
+
+sub hashref_rs {
+    my ($self) = @_;
+    $self->result_class('DBIx::Class::ResultClass::HashRefInflator');
+    return $self;
+}
+
+=head2 hashref_array( )
+
+Calls ->hashref_rs->all and returns depending on the calling context an array or an reference to an array. 
+
+    my $rs = $schema->resultset('User')->search( { } )->hashref_array;
+    print Dumper $rs;
+
+    my @rs = $schema->resultset('User')->search( { } )->hashref_array;
+    print Dumper @rs;
+
+=cut
+
+sub hashref_array {
+    return wantarray ? shift->hashref_rs->all : [ shift->hashref_rs->all ];
+}
+
+=head2 hashref_first( )
+
+Returns the first row of the resultset inflated by L<DBIx::Class::ResultClass::HashRefInflator>.
+
+    my $first_row = $schema->resultset('User')->search( { } )->hashref_first;
+    print Dumper $first_row
+
+=cut
+
+sub hashref_first {
+    return shift->hashref_rs->first;
+}
+
+=head1 AUTHOR
+
+Johannes Plunien E<lt>plu at cpan.orgE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2008 by Johannes Plunien
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+Thanks to mst for his patience.
+
+=head1 SEE ALSO
+
+=over 4 
+
+=item * L<DBIx::Class>
+
+=item * L<DBIx::Class::ResultClass::HashRefInflator>
+
+=back
+
+=cut
+
+1;

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/t/00-use.t
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/t/00-use.t	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/t/00-use.t	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,7 @@
+use Test::More tests => 1;
+
+BEGIN {
+use_ok( 'DBIx::Class::ResultSet::HashRef' );
+}
+
+diag( "Testing DBIx::Class::ResultSet::HashRef $DBIx::Class::ResultSet::HashRef::VERSION" );

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/t/10-hashref.t
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/t/10-hashref.t	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/t/10-hashref.t	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,316 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+BEGIN {
+    eval "use DBD::SQLite ();";
+    plan skip_all => 'DBD::SQLite required to run this test' if $@;
+
+    eval "use SQL::Translator ();";
+    plan skip_all => 'SQL::Translator required to run this test' if $@;
+
+    plan( tests => 10 );
+}
+
+use lib 't/lib';
+use TestSchema;
+use File::Temp;
+
+# setup
+my ( undef, $db ) = File::Temp::tempfile();
+my $schema = TestSchema->connect( "dbi:SQLite:dbname=${db}", undef, undef );
+$schema->deploy;
+
+my @users = qw/root toor daemon operator bin tty/;
+my @roles = qw/admin superuser user/;
+
+ at users = $schema->populate( 'User' => [ ['login'] => ( map { [$_] } @users ) ] );
+ at roles = $schema->populate( 'Role' => [ ['name']  => ( map { [$_] } @roles ) ] );
+
+my $u          = 1;
+my @user_roles = ();
+foreach my $user (@users) {
+    my $r = 0;
+    foreach my $role (@roles) {
+        next if $r >= $u;
+        push @user_roles, [ $user->id, $role->id ];
+        $r++;
+    }
+    $u++;
+    $u = 1 if $u > scalar @roles;
+}
+
+ at user_roles = $schema->populate( 'UserRole' => [ [qw/user_id role_id/] => @user_roles ] );
+
+{
+    my $rs = $schema->resultset('User')->search(
+        {},
+        {
+            prefetch => { user_role => [qw/role/] },
+            order_by => 'me.id ASC'
+        }
+    )->hashref_array;
+
+    is_deeply(
+        $rs,
+        [
+            {
+                'id'        => '1',
+                'login'     => 'root',
+                'user_role' => [
+                    {
+                        'role' => {
+                            'id'   => '1',
+                            'name' => 'admin'
+                        },
+                        'role_id' => '1',
+                        'user_id' => '1'
+                    }
+                ]
+            },
+            {
+                'id'        => '2',
+                'login'     => 'toor',
+                'user_role' => [
+                    {
+                        'role' => {
+                            'id'   => '1',
+                            'name' => 'admin'
+                        },
+                        'role_id' => '1',
+                        'user_id' => '2'
+                    },
+                    {
+                        'role' => {
+                            'id'   => '2',
+                            'name' => 'superuser'
+                        },
+                        'role_id' => '2',
+                        'user_id' => '2'
+                    }
+                ]
+            },
+            {
+                'id'        => '3',
+                'login'     => 'daemon',
+                'user_role' => [
+                    {
+                        'role' => {
+                            'id'   => '1',
+                            'name' => 'admin'
+                        },
+                        'role_id' => '1',
+                        'user_id' => '3'
+                    },
+                    {
+                        'role' => {
+                            'id'   => '2',
+                            'name' => 'superuser'
+                        },
+                        'role_id' => '2',
+                        'user_id' => '3'
+                    },
+                    {
+                        'role' => {
+                            'id'   => '3',
+                            'name' => 'user'
+                        },
+                        'role_id' => '3',
+                        'user_id' => '3'
+                    }
+                ]
+            },
+            {
+                'id'        => '4',
+                'login'     => 'operator',
+                'user_role' => [
+                    {
+                        'role' => {
+                            'id'   => '1',
+                            'name' => 'admin'
+                        },
+                        'role_id' => '1',
+                        'user_id' => '4'
+                    }
+                ]
+            },
+            {
+                'id'        => '5',
+                'login'     => 'bin',
+                'user_role' => [
+                    {
+                        'role' => {
+                            'id'   => '1',
+                            'name' => 'admin'
+                        },
+                        'role_id' => '1',
+                        'user_id' => '5'
+                    },
+                    {
+                        'role' => {
+                            'id'   => '2',
+                            'name' => 'superuser'
+                        },
+                        'role_id' => '2',
+                        'user_id' => '5'
+                    }
+                ]
+            },
+            {
+                'id'        => '6',
+                'login'     => 'tty',
+                'user_role' => [
+                    {
+                        'role' => {
+                            'id'   => '1',
+                            'name' => 'admin'
+                        },
+                        'role_id' => '1',
+                        'user_id' => '6'
+                    },
+                    {
+                        'role' => {
+                            'id'   => '2',
+                            'name' => 'superuser'
+                        },
+                        'role_id' => '2',
+                        'user_id' => '6'
+                    },
+                    {
+                        'role' => {
+                            'id'   => '3',
+                            'name' => 'user'
+                        },
+                        'role_id' => '3',
+                        'user_id' => '6'
+                    }
+                ]
+            }
+        ],
+        'hashref_array'
+    );
+}
+
+{
+    my @rs = $schema->resultset('User')->search( {}, { order_by => 'me.id ASC' } )->hashref_array;
+    is_deeply(
+        \@rs,
+        [
+            {
+                'id'    => '1',
+                'login' => 'root'
+            },
+            {
+                'id'    => '2',
+                'login' => 'toor'
+            },
+            {
+                'id'    => '3',
+                'login' => 'daemon'
+            },
+            {
+                'id'    => '4',
+                'login' => 'operator'
+            },
+            {
+                'id'    => '5',
+                'login' => 'bin'
+            },
+            {
+                'id'    => '6',
+                'login' => 'tty'
+            }
+        ]
+    );
+}
+
+{
+    my $rs = $schema->resultset('User')->search(
+        {},
+        {
+            prefetch => { user_role => [qw/role/] },
+            order_by => 'me.id DESC'
+        }
+    )->hashref_rs->next;
+    is_deeply(
+        $rs,
+        {
+            'id'        => '6',
+            'login'     => 'tty',
+            'user_role' => [
+                {
+                    'role' => {
+                        'id'   => '1',
+                        'name' => 'admin'
+                    },
+                    'role_id' => '1',
+                    'user_id' => '6'
+                },
+                {
+                    'role' => {
+                        'id'   => '2',
+                        'name' => 'superuser'
+                    },
+                    'role_id' => '2',
+                    'user_id' => '6'
+                },
+                {
+                    'role' => {
+                        'id'   => '3',
+                        'name' => 'user'
+                    },
+                    'role_id' => '3',
+                    'user_id' => '6'
+                }
+            ]
+        },
+        'hashref_rs->next'
+    );
+}
+
+{
+    my $expected_users = [
+        {
+            'id'    => '1',
+            'login' => 'root'
+        },
+        {
+            'id'    => '2',
+            'login' => 'toor'
+        },
+        {
+            'id'    => '3',
+            'login' => 'daemon'
+        },
+        {
+            'id'    => '4',
+            'login' => 'operator'
+        },
+        {
+            'id'    => '5',
+            'login' => 'bin'
+        },
+        {
+            'id'    => '6',
+            'login' => 'tty'
+        }
+    ];
+    my $rs = $schema->resultset('User')->search( {}, { order_by => 'me.id ASC' } )->hashref_rs;
+    while ( my $row = $rs->next ) {
+        my $user = shift(@$expected_users);
+        is_deeply( $row, $user, "hashref_rs in while loop, user: " . $user->{login} );
+    }
+}
+
+{
+    my $first_row = $schema->resultset('User')->search( { login => 'root' } )->hashref_first;
+    is_deeply(
+        $first_row,
+        {
+            'id'    => '1',
+            'login' => 'root'
+        },
+        "hashref_first"
+    );
+}

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/t/98-pod_coverage.t
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/t/98-pod_coverage.t	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/t/98-pod_coverage.t	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/t/99-pod.t
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/t/99-pod.t	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/t/99-pod.t	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/Role.pm
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/Role.pm	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/Role.pm	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,27 @@
+package TestSchema::Role;
+
+use strict;
+use warnings;
+use base qw( DBIx::Class );
+
+__PACKAGE__->load_components(qw( Core ));
+__PACKAGE__->table('role');
+__PACKAGE__->add_columns(
+    id => {
+        data_type         => 'int',
+        is_auto_increment => 1,
+        is_nullable       => 0,
+        default_value     => undef,
+        size              => 10,
+    },
+    name => {
+        data_type   => 'varchar',
+        size        => 16,
+        is_nullable => 0,
+    },
+);
+__PACKAGE__->set_primary_key("id");
+__PACKAGE__->has_many( user_role => 'TestSchema::UserRole', 'role_id' );
+__PACKAGE__->many_to_many( users => 'user_role', 'user' );
+
+1;

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/User.pm
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/User.pm	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/User.pm	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,28 @@
+package TestSchema::User;
+
+use strict;
+use warnings;
+use base qw( DBIx::Class );
+
+__PACKAGE__->load_components(qw( Core ));
+__PACKAGE__->table('user');
+__PACKAGE__->add_columns(
+    id => {
+        data_type         => 'int',
+        is_auto_increment => 1,
+        is_nullable       => 0,
+        default_value     => undef,
+        size              => 10,
+    },
+    login => {
+        data_type   => 'varchar',
+        size        => 16,
+        is_nullable => 0,
+    },
+);
+__PACKAGE__->set_primary_key("id");
+__PACKAGE__->has_many( user_role => 'TestSchema::UserRole', 'user_id' );
+__PACKAGE__->many_to_many( roles => 'user_role', 'role' );
+__PACKAGE__->resultset_class('DBIx::Class::ResultSet::HashRef');
+
+1;

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/UserRole.pm
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/UserRole.pm	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema/UserRole.pm	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,25 @@
+package TestSchema::UserRole;
+
+use strict;
+use warnings;
+use base qw( DBIx::Class );
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("user_role");
+__PACKAGE__->add_columns(
+    user_id => {
+        data_type     => "INT",
+        default_value => undef,
+        is_nullable   => 0,
+        size          => 10
+    },
+    role_id => {
+        data_type     => "INT",
+        default_value => undef,
+        is_nullable   => 0,
+        size          => 10
+    },
+);
+__PACKAGE__->set_primary_key(qw/user_id role_id/);
+__PACKAGE__->belongs_to( user => 'TestSchema::User', { id => "user_id" } );
+__PACKAGE__->belongs_to( role => 'TestSchema::Role', { id => "role_id" } );

Added: DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema.pm
===================================================================
--- DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema.pm	                        (rev 0)
+++ DBIx-Class-ResultSet-HashRef/1.000/trunk/t/lib/TestSchema.pm	2008-06-14 14:03:05 UTC (rev 4497)
@@ -0,0 +1,9 @@
+package TestSchema;
+
+use strict;
+use warnings;
+use base qw( DBIx::Class::Schema );
+
+__PACKAGE__->load_classes;
+
+1;




More information about the Bast-commits mailing list