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