File Coverage

blib/lib/DBIx/PgLink/Adapter/XBase.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package DBIx::PgLink::Adapter::XBase;
2              
3 1     1   2129 use Moose;
  0            
  0            
4              
5             extends 'DBIx::PgLink::Adapter';
6              
7             with 'DBIx::PgLink::Adapter::Roles::EmulateColumnInfo';
8              
9             has '+are_transactions_supported' => (default=>0);
10             has '+include_schema_to_qualified_name' => (default=>0);
11              
12             # Fix XBase 'table_info' method
13             # Note: 'catalog' and 'schema' arguments are ignored
14             override 'table_info' => sub {
15             my ($self, $catalog, $schema, $table, $type) = @_;
16              
17             # catalog and schema ignored, type can be only 'TABLE'
18             $type =~ s/'//g;
19             return unless grep { $_ eq 'TABLE' } split /,/, $type;
20              
21             # convert 'like' pattern to regex
22             $table =~ s/_/./g;
23             $table =~ s/%/.*/g;
24              
25             my $sth = DBI::_new_sth(
26             $self->dbh,
27             {
28             'xbase_lines' =>
29             [ map { [ undef, undef, $_, 'TABLE', undef ] }
30             grep /^$table$/i, $self->dbh->tables # fixed: no name filtering
31             ]
32             }
33             );
34             $sth->STORE('NUM_OF_FIELDS', 5);
35             $sth->{'xbase_nondata_name'} = [
36             qw! TABLE_QUALIFIER TABLE_OWNER
37             TABLE_NAME TABLE_TYPE REMARKS !
38             ];
39             return $sth;
40             };
41              
42              
43             # DBD::XBase 0.241 don't understand any quoting
44             override 'quote_identifier' => sub {
45             my $self = shift;
46             my @argv = grep { defined } @_;
47             return $argv[-1]; # only last portion of name
48             };
49              
50              
51             # conversion
52              
53             # Date YYYY-MM-DD -> YYYYMMDD
54             sub to_xbase_date($) {
55             return unless defined $_[1];
56             $_[1] = "$1$2$3" if $_[1] =~ /^(\d\d\d\d)-(\d\d)-(\d\d)/;
57             }
58              
59             1;