~ubuntu-branches/ubuntu/saucy/libdbd-csv-perl/saucy-proposed

« back to all changes in this revision

Viewing changes to lib/DBD/CSV.pm

  • Committer: Bazaar Package Importer
  • Author(s): gregor herrmann, Jonathan Yu, gregor herrmann
  • Date: 2010-04-08 23:51:52 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100408235152-j0wq3jrc7y699hvx
Tags: 0.2800-1
[ Jonathan Yu ]
* New upstream release 0.27
* Rewrite control description

[ gregor herrmann ]
* New upstream release 0.28 (closes: #576672).
* Remove minimumversion patch, the test was moved to xt/. Remove build
  dependency on libtest-minimumversion-perl.
* Convert to source format 3.0 (quilt). Remove quilt framework.
* Bump versioned (build) dependencies according to new upstream
  requirements.
* debian/copyright: update years of upstream and packaging copyright; update
  formatting.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/pro/bin/perl
 
1
#!/usr/bin/perl
2
2
#
3
3
#   DBD::CSV - A DBI driver for CSV and similar structured files
4
4
#
9
9
#   The original author is Jochen Wiedmann.
10
10
#   Then maintained by Jeff Zucker
11
11
#
12
 
#   Copyright (C) 2009 by H.Merijn Brand
 
12
#   Copyright (C) 2010 by H.Merijn Brand
13
13
#   Copyright (C) 2004 by Jeff Zucker
14
14
#   Copyright (C) 1998 by Jochen Wiedmann
15
15
#
34
34
 
35
35
@ISA =   qw( DBD::File );
36
36
 
37
 
$VERSION  = "0.26";
 
37
$VERSION  = "0.28";
38
38
 
39
39
$err      = 0;          # holds error code   for DBI::err
40
40
$errstr   = "";         # holds error string for DBI::errstr
125
125
 
126
126
    # Being a bit dirty here, as SQL::Statement::Structure does not offer
127
127
    # me an interface to the data I want
128
 
    my $struct = $sth->{f_stmt}{struct} || {};
129
 
    my @cols = @{ $struct->{column_names} || [] };
 
128
    my $struct   = $sth->{f_stmt}{struct} || {};
 
129
    my @coldefs  = @{ $struct->{column_defs} || [] };
 
130
    my @colnames = map { $_->{name} || $_->{value} } @coldefs;
130
131
 
131
132
    $attr eq "TYPE"      and
132
 
        return [ map { $struct->{column_defs}{$_}{data_type}   || "CHAR" }
133
 
                    @cols ];
 
133
        return [ map { $struct->{table_defs}->{columns}{$_}{data_type}   || "CHAR" }
 
134
                    @colnames ];
134
135
 
135
136
    $attr eq "PRECISION" and
136
 
        return [ map { $struct->{column_defs}{$_}{data_length} || 0 }
137
 
                    @cols ];
 
137
        return [ map { $struct->{table_defs}->{columns}{$_}{data_length} || 0 }
 
138
                    @colnames ];
138
139
 
139
140
    $attr eq "NULLABLE"  and
140
141
        return [ map { ( grep m/^NOT NULL$/ =>
141
 
                    @{ $struct->{column_defs}{$_}{constraints} || [] } )
 
142
                    @{ $struct->{table_defs}->{columns}{$_}{constraints} || [] } )
142
143
                       ? 0 : 1 }
143
 
                    @cols ];
 
144
                    @colnames ];
144
145
 
145
146
    return $sth->SUPER::FETCH ($attr);
146
147
    } # FETCH
394
395
 
395
396
All SQL processing for DBD::CSV is done by the L<SQL::Statement> module.
396
397
Features include joins, aliases, built-in and user-defined functions,
397
 
and more.  See L<SQL::Statement::Sytax> for a description of the SQL
 
398
and more.  See L<SQL::Statement::Syntax> for a description of the SQL
398
399
syntax supported in DBD::CSV.
399
400
 
400
401
Table names are case insensitive unless quoted.
703
704
 
704
705
With this option set, all new statement handles will set C<always_quote>
705
706
and C<blank_is_undef> in the CSV parser and writer, so it knows how to
706
 
distinquish between the empty string and C<undef> or C<NULL>. You cannot
 
707
distinguish between the empty string and C<undef> or C<NULL>. You cannot
707
708
reset it with a false value. You can pass it to connect, or set it later:
708
709
 
709
710
  $dbh = DBI->connect ("dbi:CSV:", "", "", { csv_null => 1 });
758
759
=item skip_first_row
759
760
 
760
761
By default DBD::CSV assumes that column names are stored in the first row
761
 
of the CSV file and sanitzes them (see C<raw_header> below). If this is
 
762
of the CSV file and sanitizes them (see C<raw_header> below). If this is
762
763
not the case, you can supply an array ref of table names with the
763
764
I<col_names> attribute. In that case the attribute I<skip_first_row> will
764
765
be set to FALSE.
934
935
 
935
936
=head1 COPYRIGHT AND LICENSE
936
937
 
937
 
Copyright (C) 2009      by H.Merijn Brand
 
938
Copyright (C) 2009-2010 by H.Merijn Brand
938
939
Copyright (C) 2004-2009 by Jeff Zucker
939
940
Copyright (C) 1998-2004 by Jochen Wiedmann
940
941