Commit | Line | Data |
75d07914 |
1 | package DBIx::Class::Storage::DBI::MSSQL; |
3885cff6 |
2 | |
75d07914 |
3 | use strict; |
4 | use warnings; |
3885cff6 |
5 | |
48fe9087 |
6 | use base qw/DBIx::Class::Storage::DBI::AmbiguousGlob DBIx::Class::Storage::DBI/; |
2ad62d97 |
7 | use mro 'c3'; |
3885cff6 |
8 | |
ac93965c |
9 | __PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks::MSSQL'); |
10 | |
d4f16b21 |
11 | sub _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 | |
17 | sub 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 | |
25 | sub sqlt_type { 'SQLServer' } |
26 | |
27 | sub _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 |
37 | 1; |
3885cff6 |
38 | |
75d07914 |
39 | =head1 NAME |
3885cff6 |
40 | |
41 | DBIx::Class::Storage::DBI::MSSQL - Storage::DBI subclass for MSSQL |
42 | |
75d07914 |
43 | =head1 SYNOPSIS |
3885cff6 |
44 | |
81092e2d |
45 | This subclass supports MSSQL, and can in theory be used directly |
46 | via the C<storage_type> mechanism: |
3885cff6 |
47 | |
48 | $schema->storage_type('::DBI::MSSQL'); |
81092e2d |
49 | $schema->connect_info('dbi:....', ...); |
50 | |
51 | However, as there is no L<DBD::MSSQL>, you will probably want to use |
52 | one of the other DBD-specific MSSQL classes, such as |
53 | L<DBIx::Class::Storage::DBI::Sybase::MSSQL>. These classes will |
54 | merge this class with a DBD-specific class to obtain fully |
55 | correct 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 | |
65 | The resulting parser handles the MSSQL C<DATETIME> type, but is almost |
66 | certainly not sufficient for the other MSSQL 2008 date/time types. |
67 | |
75d07914 |
68 | =head1 AUTHORS |
3885cff6 |
69 | |
75d07914 |
70 | Brian Cassidy <bricas@cpan.org> |
3885cff6 |
71 | |
75d07914 |
72 | =head1 LICENSE |
3885cff6 |
73 | |
75d07914 |
74 | You may distribute this code under the same terms as Perl itself. |
3885cff6 |
75 | |
75d07914 |
76 | =cut |