Commit | Line | Data |
2edf3352 |
1 | package DBIx::Class::Storage::DBI::ADO::Microsoft_SQL_Server::Cursor; |
2 | |
3 | use strict; |
4 | use warnings; |
616ca57f |
5 | |
2edf3352 |
6 | use base 'DBIx::Class::Storage::DBI::Cursor'; |
7 | use mro 'c3'; |
616ca57f |
8 | |
2edf3352 |
9 | use DBIx::Class::Storage::DBI::ADO::CursorUtils qw/_normalize_guids _strip_trailing_binary_nulls/; |
616ca57f |
10 | use DBIx::Class::ResultSource::FromSpec::Util 'fromspec_columns_info'; |
2edf3352 |
11 | use namespace::clean; |
12 | |
13 | =head1 NAME |
14 | |
15 | DBIx::Class::Storage::DBI::ADO::Microsoft_SQL_Server::Cursor - Remove trailing |
16 | NULLs in binary data and normalize GUIDs for MSSQL over ADO |
17 | |
18 | =head1 DESCRIPTION |
19 | |
20 | This class is for removing trailing C<NULL>s from binary data and removing braces |
21 | from GUIDs retrieved from Microsoft SQL Server over ADO. |
22 | |
23 | You probably don't want to be here, see |
24 | L<DBIx::Class::Storage::DBI::ADO::Microsoft_SQL_Server> for information on the |
25 | Microsoft SQL Server driver for ADO and L<DBIx::Class::Storage::DBI::MSSQL> for |
26 | the Microsoft SQL Server driver base class. |
27 | |
28 | Unfortunately when using L<DBD::ADO>, binary data comes back padded with |
29 | trailing C<NULL>s and GUIDs come back wrapped in braces, the purpose of this |
30 | class is to remove the C<NULL>s and braces. |
31 | L<DBIx::Class::Storage::DBI::ADO::Microsoft_SQL_Server> sets |
32 | L<cursor_class|DBIx::Class::Storage::DBI/cursor_class> to this class by |
33 | default. It is overridable via your |
34 | L<connect_info|DBIx::Class::Storage::DBI/connect_info>. |
35 | |
36 | You can use L<DBIx::Class::Cursor::Cached> safely with this class and not lose |
37 | the binary data normalizing functionality, |
38 | L<::Cursor::Cached|DBIx::Class::Cursor::Cached> uses the underlying class data |
39 | for the inner cursor class. |
40 | |
41 | =cut |
42 | |
a2f22854 |
43 | sub next { |
44 | my $self = shift; |
2edf3352 |
45 | |
a2f22854 |
46 | my @row = $self->next::method(@_); |
2edf3352 |
47 | |
616ca57f |
48 | $self->{_colinfos} ||= fromspec_columns_info($self->args->[0]); |
2edf3352 |
49 | |
a2f22854 |
50 | _normalize_guids( |
51 | $self->args->[1], |
52 | $self->{_colinfos}, |
53 | \@row, |
54 | $self->storage |
55 | ); |
2edf3352 |
56 | |
a2f22854 |
57 | _strip_trailing_binary_nulls( |
58 | $self->args->[1], |
59 | $self->{_colinfos}, |
60 | \@row, |
61 | $self->storage |
62 | ); |
2edf3352 |
63 | |
64 | return @row; |
65 | } |
66 | |
a2f22854 |
67 | sub all { |
68 | my $self = shift; |
2edf3352 |
69 | |
a2f22854 |
70 | my @rows = $self->next::method(@_); |
2edf3352 |
71 | |
616ca57f |
72 | $self->{_colinfos} ||= fromspec_columns_info($self->args->[0]); |
2edf3352 |
73 | |
74 | for (@rows) { |
a2f22854 |
75 | _normalize_guids( |
76 | $self->args->[1], |
77 | $self->{_colinfos}, |
78 | $_, |
79 | $self->storage |
80 | ); |
81 | |
82 | _strip_trailing_binary_nulls( |
83 | $self->args->[1], |
84 | $self->{_colinfos}, |
85 | $_, |
86 | $self->storage |
87 | ); |
2edf3352 |
88 | } |
89 | |
90 | return @rows; |
91 | } |
92 | |
a2bd3796 |
93 | =head1 FURTHER QUESTIONS? |
2edf3352 |
94 | |
a2bd3796 |
95 | Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>. |
2edf3352 |
96 | |
a2bd3796 |
97 | =head1 COPYRIGHT AND LICENSE |
2edf3352 |
98 | |
a2bd3796 |
99 | This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE> |
100 | by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can |
101 | redistribute it and/or modify it under the same terms as the |
102 | L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>. |
2edf3352 |
103 | |
104 | =cut |
105 | |
a2bd3796 |
106 | 1; |
107 | |
2edf3352 |
108 | # vim:sts=2 sw=2: |