blib/lib/DBIx/DBO/DBD/MariaDB.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 24 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 100 CC 6 SCAR 16.8
CC
6
Cov
0%
_calc_found_rows
12.0
_get_table_schema
6.0
_build_sql_select
6.0
CRAP 5.4
1 use 5.014;
2 use warnings;
3  
4 package # hide from PAUSE
5 DBIx::DBO::DBD::MariaDB;
6 use Carp qw(croak);
7  
8 sub _get_table_schema {
9 my($class, $me, $table) = @_;
10  
11 my($schema) = $me->selectrow_array('SELECT DATABASE()');
12 croak 'Invalid table: '.$class->_qi($me, $table).' (No database selected)' unless defined $schema;
13 return $schema;
14 }
15  
16 sub _unquote_table {
17 $_[2] =~ /^(?:(`|"|)(.+)\1\.|)(`|"|)(.+)\3$/ or croak "Invalid table: \"$_[2]\"";
18 return ($2, $4);
19 }
20  
21 sub _save_last_insert_id {
22 my($class, $me, $sth) = @_;
23  
24 return $sth->last_insert_id;
25 }
26  
27 sub _get_config {
28 my $class = shift;
29 my $val = $class->SUPER::_get_config(@_);
30 # In MariaDB support for LIMIT on UPDATE/DELETE is on by default
31 $val // ($_[0] eq 'LimitRowUpdate' || $_[0] eq 'LimitRowDelete' || undef);
32 }
33  
34 # Query
35 sub _calc_found_rows {
36 my($class, $me) = @_;
37  
38 # If sth and sql =~ SQL_CALC_FOUND_ROWS, then SELECT FOUND_ROWS
39 # If no sth and CalcFoundRows, then run, and SELECT FOUND_ROWS
40 if ($me->{sth}
41 ? $me->{sql} =~ / SQL_CALC_FOUND_ROWS /
42 : ($me->config('CalcFoundRows') and $me->run or croak $me->rdbh->errstr)) {
43 return $me->{Found_Rows} = ($class->_selectrow_array($me, 'SELECT FOUND_ROWS()'))[0];
44 }
45 $class->SUPER::_calc_found_rows($me);
46 }
47  
48 sub _build_sql_select {
49 my($class, $me) = @_;
50  
51 my $sql = $class->SUPER::_build_sql_select($me);
52 $sql =~ s/^SELECT /SELECT SQL_CALC_FOUND_ROWS / if $me->config('CalcFoundRows') and not $me->{build_data}{_super_query};
53 return $sql;
54 }
55  
56 # MariaDB doesn't allow the use of aliases in the WHERE clause
57 sub _alias_preference {
58 my($class, $me, $method) = @_;
59 $method ||= ((caller(2))[3] =~ /\b(\w+)$/)[0];
60 return 0 if $method eq 'join_on' or $method eq 'where';
61 return 1;
62 }
63  
64 sub _bulk_insert {
65 shift->_fast_bulk_insert(@_);
66 }
67  
68 1;