File Coverage

blib/lib/Class/DBI/Loader/Oracle.pm
Criterion Covered Total %
statement 18 33 54.5
branch 0 4 0.0
condition n/a
subroutine 6 8 75.0
pod n/a
total 24 45 53.3


line stmt bran cond sub pod time code
1             package Class::DBI::Loader::Oracle;
2              
3 1     1   28469 use warnings;
  1         3  
  1         51  
4 1     1   5 use strict;
  1         2  
  1         38  
5 1     1   9591 use DBI;
  1         36570  
  1         100  
6 1     1   15 use Carp;
  1         2  
  1         466  
7             require Class::DBI::Oracle;
8 1     1   7 use base 'Class::DBI::Loader::Generic';
  1         38  
  1         2113  
9 1     1   33848 use vars '$VERSION';
  1         2  
  1         347  
10             $VERSION = '0.02';
11              
12 0     0     sub _db_class { return 'Class::DBI::Oracle' }
13              
14             sub _tables {
15 0     0     my $self = shift;
16              
17 0           my $user = uc $self->{_datasource}->[1];
18             # handle user strings of the form user@sid or user/password@sid
19             # we want only the user (schema) name
20 0           $user =~ s/^(\w+)[@\/]?.*$/$1/;
21              
22 0 0         my $dbh = DBI->connect(@{$self->{_datasource}}) or croak($DBI::errstr);
  0            
23 0           my @tables;
24 0           for my $table ( $dbh->tables(undef, $user, '%', 'TABLE') ) { #catalog, schema, table, type
25 0           my $quoter = $dbh->get_info(29);
26 0           $table =~ s/$quoter//g;
27              
28             # remove "user." (schema) prefixes
29 0           $table =~ s/\w+\.//;
30              
31 0           $table = lc $table;
32 0 0         push @tables, $1
33             if $table =~ /\A(\w+)\z/;
34             }
35 0           $dbh->disconnect;
36 0           return @tables;
37             }
38              
39             =head1 NAME
40              
41             Class::DBI::Loader::Oracle - Class::DBI::Loader Oracle Implementation.
42              
43             =head1 SYNOPSIS
44              
45             use Class::DBI::Loader;
46              
47             # $loader is a Class::DBI::Loader::Oracle
48             my $loader = Class::DBI::Loader->new(
49             dsn => $dsn, # "dbi:Oracle:", "dbi:Oracle:DB", ...
50             user => $user, # "user", "user@DB", "user/pass", ...
51             password => $password, # "pass", "", ...
52             namespace => "Data",
53             );
54             my $class = $loader->find_class('film'); # $class => Data::Film
55             my $obj = $class->retrieve(1);
56              
57             =head1 DESCRIPTION
58              
59             See L, L.
60              
61             =head1 SEE ALSO
62              
63             L, L
64              
65             =head1 TODO
66              
67             This module needs a new maintainer, because I no longer use L and
68             have no further interest in maintaining this module. And yes, this includes the
69             RT wishlist request for relationships support.
70              
71             =head1 BUGS
72              
73             Please report any bugs or feature requests to
74             C, or through the web interface at
75             L.
76             I will be notified, and then you'll automatically be notified of progress on
77             your bug as I make changes.
78              
79             =head1 ACKNOWLEDGEMENTS
80              
81             Special thanks to Frank Carnovale and Ian VanDerPoel for sharing their code, upon which this module is based. Thanks also to Jay Strauss, Johan Lindstrom and Dan Sully for their helpful comments.
82              
83             =head1 AUTHOR
84              
85             David Naughton, C<< >>
86              
87             =head1 COPYRIGHT & LICENSE
88              
89             Copyright 2005 David Naughton, All Rights Reserved.
90              
91             This program is free software; you can redistribute it and/or modify it
92             under the same terms as Perl itself.
93              
94             =cut
95              
96             1; # End of Class::DBI::Loader::Oracle