X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FMSSQL.pm;h=9cde4b9c172256420427b636123678df01317a48;hb=d5dedbd62928f65a9071b4d9b6d56c6b663a073b;hp=3c6e911c4361f44b3b59ff483bea14588ab1cde7;hpb=e9657379908899b73ff92948a4cd19b6f875e10f;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index 3c6e911..9cde4b9 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -13,7 +13,7 @@ __PACKAGE__->mk_group_accessors(simple => qw/ _identity _identity_method /); -__PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks::MSSQL'); +__PACKAGE__->sql_maker_class('DBIx::Class::SQLMaker::MSSQL'); sub _set_identity_insert { my ($self, $table) = @_; @@ -144,7 +144,7 @@ sub last_insert_id { shift->_identity } # # MSSQL is retarded wrt ordered subselects. One needs to add a TOP -# to *all* subqueries, but one also can't use TOP 100 PERCENT +# to *all* subqueries, but one also *can't* use TOP 100 PERCENT # http://sqladvice.com/forums/permalink/18496/22931/ShowThread.aspx#22931 # sub _select_args_to_query { @@ -196,37 +196,26 @@ sub datetime_parser_type { sub sqlt_type { 'SQLServer' } -sub sql_maker { +sub sql_limit_dialect { my $self = shift; - unless ($self->_sql_maker) { - unless ($self->{_sql_maker_opts}{limit_dialect}) { - my $have_rno = 0; + my $supports_rno = 0; - if (exists $self->_server_info->{normalized_dbms_version}) { - $have_rno = 1 if $self->_server_info->{normalized_dbms_version} >= 9; - } - else { - # User is connecting via DBD::Sybase and has no permission to run - # stored procedures like xp_msver, or version detection failed for some - # other reason. - # So, we use a query to check if RNO is implemented. - try { - $self->_get_dbh->selectrow_array('SELECT row_number() OVER (ORDER BY rand())'); - $have_rno = 1; - }; - } - - $self->{_sql_maker_opts} = { - limit_dialect => ($have_rno ? 'RowNumberOver' : 'Top'), - %{$self->{_sql_maker_opts}||{}} - }; - } - - my $maker = $self->next::method (@_); + if (exists $self->_server_info->{normalized_dbms_version}) { + $supports_rno = 1 if $self->_server_info->{normalized_dbms_version} >= 9; + } + else { + # User is connecting via DBD::Sybase and has no permission to run + # stored procedures like xp_msver, or version detection failed for some + # other reason. + # So, we use a query to check if RNO is implemented. + try { + $self->_get_dbh->selectrow_array('SELECT row_number() OVER (ORDER BY rand())'); + $supports_rno = 1; + }; } - return $self->_sql_maker; + return $supports_rno ? 'RowNumberOver' : 'Top'; } sub _ping {