| 1 | package DBIx::QuickORM::WhereBuilder::SQLAbstract; | ||||||||||||||||||||||||||||||||||||||
| 2 | 262 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | 262 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||
| 5 | 262 | our $VERSION = '0.000031'; | |||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 262 | ▶ | use Role::Tiny::With qw/with/; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | 262 | with 'DBIx::QuickORM::Role::WhereBuilder'; | |||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||
| 10 | =pod | ||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||
| 12 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||
| 16 | DBIx::QuickORM::WhereBuilder::SQLAbstract - Any where, through SQL::Abstract. | ||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||
| 20 | Takes every C<where> and renders it as | ||||||||||||||||||||||||||||||||||||||
| 21 | L<DBIx::QuickORM::SQLBuilder::SQLAbstract> documents: L<SQL::Abstract>'s | ||||||||||||||||||||||||||||||||||||||
| 22 | syntax, with value markers anywhere. It is the last where builder in the | ||||||||||||||||||||||||||||||||||||||
| 23 | default chain. | ||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||
| 27 | my $orm = DBIx::QuickORM->new(..., where_builders => ['DBIx::QuickORM::WhereBuilder::SQLAbstract']); | ||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | =head1 PUBLIC METHODS | ||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||
| 31 | =over 4 | ||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||
| 33 | =item $bool = DBIx::QuickORM::WhereBuilder::SQLAbstract->can_build_where($where) | ||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||
| 35 | Always true. | ||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||
| 37 | =item ($sql, \@binds) = DBIx::QuickORM::WhereBuilder::SQLAbstract->build_where($where, $source, $dialect) | ||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||
| 39 | As L<DBIx::QuickORM::Role::WhereBuilder> describes. | ||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||
| 41 | =back | ||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||
| 43 | =cut | ||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||
| 45 | # One shared SQL builder: its convert_where turns value markers into SQL::Abstract's forms, and it keeps an | ||||||||||||||||||||||||||||||||||||||
| 46 | # SQL::Abstract per quote character. Loaded at first use, since that builder loads this class. | ||||||||||||||||||||||||||||||||||||||
| 47 | 262 | my $SQL_BUILDER; | |||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | 74 | ▶ | sub can_build_where { 1 } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
can_build_where: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | 379 | ▶ | sub build_where { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
build_where: called CC=2 SCAR=9.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
build_where: not called CC=2 SCAR=9.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my ($where, $source, $dialect) = @_; | |||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my $builder = $SQL_BUILDER //= do { require DBIx::QuickORM::SQLBuilder::SQLAbstract; DBIx::QuickORM::SQLBuilder::SQLAbstract->new }; | ||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$SQL_BUILDER //= do {
require DBIx::QuickORM::SQLBuilder::SQLAbstract;
"DBIx::QuickORM::SQLBuilder::SQLAbstract"->new
}
$SQL_BUILDER //= do {
require DBIx::QuickORM::SQLBuilder::SQLAbstract;
"DBIx::QuickORM::SQLBuilder::SQLAbstract"->new
}
MC/DC0%0/2
$SQL_BUILDER //= do {
require DBIx::QuickORM::SQLBuilder::SQLAbstract;
"DBIx::QuickORM::SQLBuilder::SQLAbstract"->new
}
$SQL_BUILDER
do {
require DBIx::QuickORM::SQLBuilder::SQLAbstract;
"DBIx::QuickORM::SQLBuilder::SQLAbstract"->new
}
MC/DC0%0/2
$SQL_BUILDER //= do {
require DBIx::QuickORM::SQLBuilder::SQLAbstract;
"DBIx::QuickORM::SQLBuilder::SQLAbstract"->new
}
$SQL_BUILDER
do {
require DBIx::QuickORM::SQLBuilder::SQLAbstract;
"DBIx::QuickORM::SQLBuilder::SQLAbstract"->new
}
Truth table66%2/3
A //= B
A= $SQL_BUILDERB= do {
require DBIx::QuickORM::SQLBuilder::SQLAbstract;
"DBIx::QuickORM::SQLBuilder::SQLAbstract"->new
}
Truth table0%0/3
A //= B
A= $SQL_BUILDERB= do {
require DBIx::QuickORM::SQLBuilder::SQLAbstract;
"DBIx::QuickORM::SQLBuilder::SQLAbstract"->new
}
| |||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my ($sql, @binds) = $builder->sqla($dialect)->where($builder->convert_where($where)); | |||||||||||||||||||||||||||||||||||||
| 57 | 0 | $sql =~ s/^ WHERE //; | |||||||||||||||||||||||||||||||||||||
| 58 | 0 | return ($sql, \@binds); | |||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | 262 | 1; | |||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||||||||||||||||||