Commit | Line | Data |
4ffa5700 |
1 | package DBIx::Class::Storage::DBI::ADO::Microsoft_SQL_Server; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use base qw/ |
7 | DBIx::Class::Storage::DBI::ADO |
8 | DBIx::Class::Storage::DBI::MSSQL |
9 | /; |
10 | use mro 'c3'; |
11 | |
12 | sub _rebless { |
13 | my $self = shift; |
14 | $self->_identity_method('@@identity'); |
15 | } |
16 | |
b3857e35 |
17 | sub source_bind_attributes { |
335b0f6c |
18 | my $self = shift; |
19 | my ($source) = @_; |
8bcd9ece |
20 | |
335b0f6c |
21 | my $bind_attributes = $self->next::method(@_); |
8bcd9ece |
22 | |
335b0f6c |
23 | foreach my $column ($source->columns) { |
b3857e35 |
24 | $bind_attributes->{$column}{ado_size} ||= 8000; # max VARCHAR |
25 | } |
26 | |
27 | return $bind_attributes; |
28 | } |
29 | |
30 | sub bind_attribute_by_data_type { |
31 | my ($self, $data_type) = @_; |
32 | |
33 | my $max_size = |
34 | $self->_mssql_max_data_type_representation_size_in_bytes->{$data_type}; |
35 | |
36 | my $res = {}; |
37 | $res->{ado_size} = $max_size if $max_size; |
38 | |
39 | return $res; |
40 | } |
41 | |
42 | # approximate |
748eb620 |
43 | # XXX needs to support varchar(max) and varbinary(max) |
b3857e35 |
44 | sub _mssql_max_data_type_representation_size_in_bytes { |
45 | my $self = shift; |
46 | |
47 | my $blob_max = $self->_get_dbh->{LongReadLen} || 32768; |
48 | |
49 | return +{ |
50 | char => 8000, |
51 | varchar => 8000, |
52 | binary => 8000, |
53 | varbinary => 8000, |
54 | nchar => 8000, |
55 | nvarchar => 8000, |
56 | numeric => 100, |
57 | smallint => 100, |
58 | tinyint => 100, |
59 | smallmoney => 100, |
60 | bigint => 100, |
61 | bit => 100, |
62 | decimal => 100, |
63 | int => 100, |
64 | money => 100, |
65 | float => 100, |
66 | real => 100, |
748eb620 |
67 | uniqueidentifier => 100, |
b3857e35 |
68 | ntext => $blob_max, |
69 | text => $blob_max, |
70 | image => $blob_max, |
71 | date => 100, |
72 | datetime => 100, |
73 | datetime2 => 100, |
74 | datetimeoffset => 100, |
75 | smalldatetime => 100, |
76 | time => 100, |
77 | timestamp => 100, |
78 | } |
8bcd9ece |
79 | } |
80 | |
4ffa5700 |
81 | 1; |
82 | |
83 | =head1 NAME |
84 | |
9f0c231f |
85 | DBIx::Class::Storage::DBI::ADO::Microsoft_SQL_Server - Support for Microsoft |
4ffa5700 |
86 | SQL Server via DBD::ADO |
87 | |
88 | =head1 SYNOPSIS |
89 | |
90 | This subclass supports MSSQL server connections via L<DBD::ADO>. |
91 | |
92 | =head1 DESCRIPTION |
93 | |
94 | The MSSQL specific functionality is provided by |
95 | L<DBIx::Class::Storage::DBI::MSSQL>. |
96 | |
97 | C<_identity_method> is set to C<@@identity>, as C<SCOPE_IDENTITY()> doesn't work |
98 | with L<DBD::ADO>. See L<DBIx::Class::Storage::DBI::MSSQL/IMPLEMENTATION NOTES> |
99 | for caveats regarding this. |
100 | |
101 | =head1 AUTHOR |
102 | |
103 | See L<DBIx::Class/CONTRIBUTORS>. |
104 | |
105 | =head1 LICENSE |
106 | |
107 | You may distribute this code under the same terms as Perl itself. |
108 | |
109 | =cut |