changed the way transactions are detected for replication to work with the standard...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / MSSQL.pm
CommitLineData
75d07914 1package DBIx::Class::Storage::DBI::MSSQL;
3885cff6 2
75d07914 3use strict;
4use warnings;
3885cff6 5
48fe9087 6use base qw/DBIx::Class::Storage::DBI::AmbiguousGlob DBIx::Class::Storage::DBI/;
2ad62d97 7use mro 'c3';
3885cff6 8
ac93965c 9__PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks::MSSQL');
10
d4f16b21 11sub _dbh_last_insert_id {
12 my ($self, $dbh, $source, $col) = @_;
0e40881e 13 my ($id) = $dbh->selectrow_array('SELECT SCOPE_IDENTITY()');
75d07914 14 return $id;
15}
ed8de058 16
17sub build_datetime_parser {
18 my $self = shift;
19 my $type = "DateTime::Format::Strptime";
20 eval "use ${type}";
21 $self->throw_exception("Couldn't load ${type}: $@") if $@;
eb0323df 22 return $type->new( pattern => '%Y-%m-%d %H:%M:%S' ); # %F %T
23}
24
25sub sqlt_type { 'SQLServer' }
26
27sub _sql_maker_opts {
28 my ( $self, $opts ) = @_;
29
30 if ( $opts ) {
31 $self->{_sql_maker_opts} = { %$opts };
32 }
33
34 return { limit_dialect => 'Top', %{$self->{_sql_maker_opts}||{}} };
ed8de058 35}
3885cff6 36
75d07914 371;
3885cff6 38
75d07914 39=head1 NAME
3885cff6 40
41DBIx::Class::Storage::DBI::MSSQL - Storage::DBI subclass for MSSQL
42
75d07914 43=head1 SYNOPSIS
3885cff6 44
81092e2d 45This subclass supports MSSQL, and can in theory be used directly
46via the C<storage_type> mechanism:
3885cff6 47
48 $schema->storage_type('::DBI::MSSQL');
81092e2d 49 $schema->connect_info('dbi:....', ...);
50
51However, as there is no L<DBD::MSSQL>, you will probably want to use
52one of the other DBD-specific MSSQL classes, such as
53L<DBIx::Class::Storage::DBI::Sybase::MSSQL>. These classes will
54merge this class with a DBD-specific class to obtain fully
55correct behavior for your scenario.
3885cff6 56
eb0323df 57=head1 METHODS
58
59=head2 last_insert_id
60
61=head2 sqlt_type
62
63=head2 build_datetime_parser
64
65The resulting parser handles the MSSQL C<DATETIME> type, but is almost
66certainly not sufficient for the other MSSQL 2008 date/time types.
67
75d07914 68=head1 AUTHORS
3885cff6 69
75d07914 70Brian Cassidy <bricas@cpan.org>
3885cff6 71
75d07914 72=head1 LICENSE
3885cff6 73
75d07914 74You may distribute this code under the same terms as Perl itself.
3885cff6 75
75d07914 76=cut