1 package DBIx::Class::Storage::DBI::ADO::Microsoft_SQL_Server;
7 DBIx::Class::Storage::DBI::ADO
8 DBIx::Class::Storage::DBI::MSSQL
14 $self->_identity_method('@@identity');
17 sub source_bind_attributes {
21 my $bind_attributes = $self->next::method(@_);
23 foreach my $column ($source->columns) {
24 $bind_attributes->{$column}{ado_size} ||= 8000; # max VARCHAR
27 return $bind_attributes;
30 sub bind_attribute_by_data_type {
31 my ($self, $data_type) = @_;
33 ($data_type = lc($data_type)) =~ s/\s+.*//;
36 $self->_mssql_max_data_type_representation_size_in_bytes->{$data_type};
39 $res->{ado_size} = $max_size if $max_size;
45 # XXX needs to support varchar(max) and varbinary(max)
46 sub _mssql_max_data_type_representation_size_in_bytes {
49 my $blob_max = $self->_get_dbh->{LongReadLen} || 32768;
71 uniqueidentifier => 100,
78 datetimeoffset => 100,
86 xml => $blob_max, # ???
88 # some non-MSSQL types
101 DBIx::Class::Storage::DBI::ADO::Microsoft_SQL_Server - Support for Microsoft
102 SQL Server via DBD::ADO
106 This subclass supports MSSQL server connections via L<DBD::ADO>.
110 The MSSQL specific functionality is provided by
111 L<DBIx::Class::Storage::DBI::MSSQL>.
117 C<_identity_method> is set to C<@@identity>, as C<SCOPE_IDENTITY()> doesn't work
118 with L<DBD::ADO>. See L<DBIx::Class::Storage::DBI::MSSQL/IMPLEMENTATION NOTES>
119 for caveats regarding this.
121 =head3 truncation bug
123 There is a bug with MSSQL ADO providers where data gets truncated based on the
124 size of the bind sizes in the first prepare call:
126 L<https://rt.cpan.org/Ticket/Display.html?id=52048>
128 The C<ado_size> workaround is used (see L<DBD::ADO/"ADO Providers">) with the
129 approximate maximum size of the data_type of the bound column, or 8000 (maximum
130 VARCHAR size) if the data_type is not available.
132 This code is incomplete and may be buggy. Particularly, C<VARCHAR(MAX)> is not
133 supported yet. The data_type list for other DBs is also incomplete. Please
134 report problems (and send patches.)
138 See L<DBIx::Class/CONTRIBUTORS>.
142 You may distribute this code under the same terms as Perl itself.