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