X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FMSSQL.pm;h=3a1f86885f1b25273c9521de2614886139cecf4d;hb=7f32c82b6791c30615bd6da46063e2a80be3ebc5;hp=6634c5964cf514000fe634e6b93d5c596dcdd53e;hpb=a9f32dbced12b2b6c4f8b8a7aa142d5922350830;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index 6634c59..3a1f868 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -3,12 +3,14 @@ package DBIx::Class::Storage::DBI::MSSQL; use strict; use warnings; -use base qw/DBIx::Class::Storage::DBI/; +use base qw/DBIx::Class::Storage::DBI::AmbiguousGlob DBIx::Class::Storage::DBI/; +use mro 'c3'; -sub last_insert_id { - my $self = shift; - my ($id) = - $self->dbh_do( sub { shift->selectrow_array('SELECT @@IDENTITY' ) } ); +__PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks::MSSQL'); + +sub _dbh_last_insert_id { + my ($self, $dbh, $source, $col) = @_; + my ($id) = $dbh->selectrow_array('SELECT SCOPE_IDENTITY()'); return $id; } @@ -17,7 +19,19 @@ sub build_datetime_parser { my $type = "DateTime::Format::Strptime"; eval "use ${type}"; $self->throw_exception("Couldn't load ${type}: $@") if $@; - return $type->new( pattern => '%m/%d/%Y %H:%M:%S' ); + return $type->new( pattern => '%Y-%m-%d %H:%M:%S' ); # %F %T +} + +sub sqlt_type { 'SQLServer' } + +sub _sql_maker_opts { + my ( $self, $opts ) = @_; + + if ( $opts ) { + $self->{_sql_maker_opts} = { %$opts }; + } + + return { limit_dialect => 'Top', %{$self->{_sql_maker_opts}||{}} }; } 1; @@ -40,6 +54,17 @@ L. These classes will merge this class with a DBD-specific class to obtain fully correct behavior for your scenario. +=head1 METHODS + +=head2 last_insert_id + +=head2 sqlt_type + +=head2 build_datetime_parser + +The resulting parser handles the MSSQL C type, but is almost +certainly not sufficient for the other MSSQL 2008 date/time types. + =head1 AUTHORS Brian Cassidy