| 1 | package DBIO::Sybase::SQLMaker; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Sybase ASE-specific SQL generation for DBIO | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 16 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 16 | ▶ | use base qw( DBIO::SQLMaker ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 53 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 53 | my $self = shift->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # copy first: the table of render ops may be shared with other makers | ||||||||||||||||||||||||||||||||||||||||||
| 17 | $self->{render_op} = { | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 53 | %{ $self->{render_op} }, | |||||||||||||||||||||||||||||||||||||||||
| 19 | nulls_first => '_render_op_nulls', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | nulls_last => '_render_op_nulls', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 53 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 19 | ▶ | sub _order_by_chunks { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_order_by_chunks: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 19 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 19 | local $self->{_sybase_nulls_chunking} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 19 | return $self->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 23 | ▶ | sub _render_op_nulls { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render_op_nulls: called CC=6 SCAR=18.8
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 23 | my ($self, $op, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 23 | my ($node) = @$args; | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | return $self->_render_unop_postfix($op, $args) | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 23 | ▶ | if $self->{_sybase_nulls_chunking}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 11 | my $expr = $node; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 11 | ▶ | if (ref $node eq 'HASH' and ref $node->{-op} eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $node eq "HASH" and ref $node->{"-op"} eq "ARRAY" and $node->{"-op"}[0] =~ /\A(?:asc|desc)\z/
ref $node eq "HASH" and ref $node->{"-op"} eq "ARRAY"
MC/DC0%0/3
ref $node eq "HASH" and ref $node->{"-op"} eq "ARRAY" and $node->{"-op"}[0] =~ /\A(?:asc|desc)\z/
ref $node eq "HASH"
ref $node->{"-op"} eq "ARRAY"
$node->{"-op"}[0] =~ /\A(?:asc|desc)\z/
Truth table25%1/4
A and B and C
A= ref $node eq "HASH"B= ref $node->{"-op"} eq "ARRAY"C= $node->{"-op"}[0] =~ /\A(?:asc|desc)\z/
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | and $node->{-op}[0] =~ /\A(?:asc|desc)\z/) { | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 11 | $expr = $node->{-op}[1]; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 11 | ▶ | my ($null, $other) = $op eq 'nulls_first' ? (0, 1) : (1, 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 11 | return $self->join_query_parts(', ', | |||||||||||||||||||||||||||||||||||||||||
| 50 | $self->join_query_parts(' ', | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 'CASE WHEN', { -op => [ 'is_null', $expr ] }, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | "THEN $null ELSE $other END", | ||||||||||||||||||||||||||||||||||||||||||
| 53 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 54 | $node, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 7 | ▶ | sub apply_limit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_limit: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 7 | my ($self, $sql, $rs_attrs, $rows, $offset) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 7 | return $self->_GenericSubQ($sql, $rs_attrs, $rows, $offset); | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | __END__ | ||||||||||||||||||||||||||||||||||||||||||