| 1 | package DBIx::Class::Storage::DBI::SQLAnywhere::Cursor; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use base 'DBIx::Class::Storage::DBI::Cursor'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | DBIx::Class::Storage::DBI::SQLAnywhere::Cursor - GUID Support for SQL Anywhere | ||||||||||||||||||||||||||||
| 11 | over L<DBD::SQLAnywhere> | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | This class is for normalizing GUIDs retrieved from SQL Anywhere via | ||||||||||||||||||||||||||||
| 16 | L<DBD::SQLAnywhere>. | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | You probably don't want to be here, see | ||||||||||||||||||||||||||||
| 19 | L<DBIx::Class::Storage::DBI::SQLAnywhere> for information on the SQL Anywhere | ||||||||||||||||||||||||||||
| 20 | driver. | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | Unfortunately when using L<DBD::SQLAnywhere>, GUIDs come back in binary, the | ||||||||||||||||||||||||||||
| 23 | purpose of this class is to transform them to text. | ||||||||||||||||||||||||||||
| 24 | L<DBIx::Class::Storage::DBI::SQLAnywhere> sets | ||||||||||||||||||||||||||||
| 25 | L<cursor_class|DBIx::Class::Storage::DBI/cursor_class> to this class by default. | ||||||||||||||||||||||||||||
| 26 | It is overridable via your | ||||||||||||||||||||||||||||
| 27 | L<connect_info|DBIx::Class::Storage::DBI/connect_info>. | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | You can use L<DBIx::Class::Cursor::Cached> safely with this class and not lose | ||||||||||||||||||||||||||||
| 30 | the GUID normalizing functionality, | ||||||||||||||||||||||||||||
| 31 | L<::Cursor::Cached|DBIx::Class::Cursor::Cached> uses the underlying class data | ||||||||||||||||||||||||||||
| 32 | for the inner cursor class. | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =cut | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | my $unpack_guids = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 37 | 0 | my ($select, $col_infos, $data, $storage) = @_; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | for my $select_idx (0..$#$select) { | |||||||||||||||||||||||||||
| 40 | next unless ( | ||||||||||||||||||||||||||||
| 41 | 0 | ▶ | defined $data->[$select_idx] | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $data->[$select_idx] and length $data->[$select_idx] == 16
MC/DC0%0/2
defined $data->[$select_idx] and length $data->[$select_idx] == 16
defined $data->[$select_idx]
length $data->[$select_idx] == 16
Truth table0%0/3
A and B
A= defined $data->[$select_idx]B= length $data->[$select_idx] == 16
| |||||||||||||||||||||||||||||
| 42 | and | ||||||||||||||||||||||||||||
| 43 | length($data->[$select_idx]) == 16 | ||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | my $selected = $select->[$select_idx]; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | my $data_type = $col_infos->{$select->[$select_idx]}{data_type} | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | $data->[$select_idx] = $storage->_uuid_to_str($data->[$select_idx]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | if $storage->_is_guid_type($data_type); | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 2 | }; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub next { | ||||||||||||||||||||||||||
|
Subroutine
next: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | my @row = $self->next::method(@_); | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | $unpack_guids->( | ||||||||||||||||||||||||||||
| 63 | $self->args->[1], | ||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $self->{_colinfos} ||= $self->storage->_resolve_column_info($self->args->[0]), | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_colinfos"} ||= $self->storage->_resolve_column_info($self->args->[0])
MC/DC0%0/2
$self->{"_colinfos"} ||= $self->storage->_resolve_column_info($self->args->[0])
$self->{"_colinfos"}
$self->storage->_resolve_column_info($self->args->[0])
Truth table0%0/3
A ||= B
A= $self->{"_colinfos"}B= $self->storage->_resolve_column_info($self->args->[0])
| |||||||||||||||||||||||||||||
| 65 | \@row, | ||||||||||||||||||||||||||||
| 66 | $self->storage | ||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | return @row; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub all { | ||||||||||||||||||||||||||
|
Subroutine
all: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | my @rows = $self->next::method(@_); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | $unpack_guids->( | ||||||||||||||||||||||||||||
| 78 | $self->args->[1], | ||||||||||||||||||||||||||||
| 79 | $self->{_colinfos} ||= $self->storage->_resolve_column_info($self->args->[0]), | ||||||||||||||||||||||||||||
| 80 | $_, | ||||||||||||||||||||||||||||
| 81 | $self->storage | ||||||||||||||||||||||||||||
| 82 | 0 | ▶ | ) for @rows; | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_colinfos"} ||= $self->storage->_resolve_column_info($self->args->[0])
MC/DC0%0/2
$self->{"_colinfos"} ||= $self->storage->_resolve_column_info($self->args->[0])
$self->{"_colinfos"}
$self->storage->_resolve_column_info($self->args->[0])
Truth table0%0/3
A ||= B
A= $self->{"_colinfos"}B= $self->storage->_resolve_column_info($self->args->[0])
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | return @rows; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head1 FURTHER QUESTIONS? | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE> | ||||||||||||||||||||||||||||
| 95 | by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can | ||||||||||||||||||||||||||||
| 96 | redistribute it and/or modify it under the same terms as the | ||||||||||||||||||||||||||||
| 97 | L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>. | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =cut | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 2 | 1; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | # vim:sts=2 sw=2: | ||||||||||||||||||||||||||||