/usr/share/perl5/Class/DBI/Plugin/Type.pm is in libclass-dbi-plugin-type-perl 0.02-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | package Class::DBI::Plugin::Type;
use strict;
use warnings;
our $VERSION = '0.02';
sub import {
no strict 'refs';
my $caller = caller();
#if ($caller->isa("Class::DBI::mysql") and
# $caller->can("column_type")) {
# return; # My work here is done
#}
return if $caller->can("sql_dummy");
$caller->set_sql(dummy => <<'');
SELECT *
FROM __TABLE__
WHERE 1=0
$caller->mk_classdata("_types");
*{$caller."::column_type"} = sub {
my ($self, $column) = @_;
if (!$self->_types) {
my $sth = $self->sql_dummy;
$sth->execute;
my %hash;
@hash{@{$sth->{NAME}}} =
map {
my $info = scalar $self->db_Main->type_info($_);
if ($info) { $info->{TYPE_NAME} }
else { $_ } # Typeless databases (SQLite)
}
@{$sth->{TYPE}};
$sth->finish;
$self->_types(\%hash);
}
return $self->_types->{$column};
}
}
1;
__END__
=head1 NAME
Class::DBI::Plugin::Type - Determine type information for columns
=head1 SYNOPSIS
package Music::Artist;
use base 'Class::DBI';
use Class::DBI::Plugin::Type;
Music::Artist->table('artist');
Music::Artist->columns(All => qw/artistid name/);
print Music::Artist->column_type("artistid"); # integer
=head1 DESCRIPTION
This module allows C<Class::DBI>-based classes to query their columns
for data type information in a database-independent manner.
=head1 SEE ALSO
L<Class::DBI::AsForm>
=head1 AUTHOR
Simon Cozens, E<lt>simon@cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright 2004 by Simon Cozens
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
This module was generously sponsored by the Perl Foundation.
=cut
|