blib/lib/DBIx/QuickORM/Role/WhereBuilder.pm

filter: Statementstmt 100% 12 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 15 / 15 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/DBIx/QuickORM/Role/Source.pm ↑ Summary
1 package DBIx::QuickORM::Role::WhereBuilder;
2 263 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 263 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 263 our $VERSION = '0.000031';
6  
7 263 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =pod
10  
11 =encoding UTF-8
12  
13 =head1 NAME
14  
15 DBIx::QuickORM::Role::WhereBuilder - The interface a handle's WHERE is rendered through.
16  
17 =head1 DESCRIPTION
18  
19 The SQL builder renders a handle's C<where> through a chain of where
20 builders: the first whose C<can_build_where> is true builds it. The chain is
21 the ORM's C<where_builders>, or the handle's when set. The default chain is
22 L<DBIx::QuickORM::WhereBuilder::RawSQL>,
23 L<DBIx::QuickORM::WhereBuilder::Simple>, then
24 L<DBIx::QuickORM::WhereBuilder::SQLAbstract>, which takes everything.
25  
26 Only the C<WHERE> goes through the chain. C<having> and C<order_by> do not.
27  
28 A where builder is a class or an object, and its methods are called on it as
29 given.
30  
31 =head1 SYNOPSIS
32  
33 package My::WhereBuilder;
34 use Role::Tiny::With qw/with/;
35 with 'DBIx::QuickORM::Role::WhereBuilder';
36  
37 sub can_build_where { my ($class, $where) = @_; ... }
38 sub build_where { my ($class, $where, $source, $dialect) = @_; ... return ($sql, \@binds) }
39  
40 =head1 REQUIRED METHODS
41  
42 =over 4
43  
44 =item $bool = $builder->can_build_where($where)
45  
46 True when this builder renders C<$where>. The chain asks each builder in
47 order until one says true, for every C<where> built, so keep it cheap.
48  
49 =item ($sql, \@binds) = $builder->build_where($where, $source, $dialect)
50  
51 The condition without the C<WHERE> keyword, or an empty string for none, and
52 its binds. Binds are C<[$field, $value]> pairs as
53 L<DBIx::QuickORM::Role::SQLBuilder> describes them. C<$source> is a
54 L<DBIx::QuickORM::Role::Source> and C<$dialect> a L<DBIx::QuickORM::Dialect>.
55  
56 =back
57  
58 =cut
59  
60 263 requires qw/can_build_where build_where/;
61  
62 263 1;
63  
64 __END__
« blib/lib/DBIx/QuickORM/Role/Source.pm ↑ Summary