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