| 1 | package DBIO::MSSQL::SQLMaker; | ||
| 2 | # ABSTRACT: MSSQL-specific SQL generation for DBIO | ||
| 3 | |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | ▶ | use base qw( DBIO::SQLMaker ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | 0 | ▶ | sub apply_limit { |
|
Subroutine
apply_limit: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 12 | 0 | my ($self, $sql, $rs_attrs, $rows, $offset) = @_; | |
| 13 | 0 | return $self->_RowNumberOver($sql, $rs_attrs, $rows, $offset); | |
| 14 | } | ||
| 15 | |||
| 16 | # | ||
| 17 | # MSSQL does not support ... OVER() ... RNO limits | ||
| 18 | # | ||
| 19 | 0 | ▶ | sub _rno_default_order { |
|
Subroutine
_rno_default_order: not called CC=1 SCAR=6.9
| |||
| 20 | 0 | return \ '(SELECT(1))'; | |
| 21 | } | ||
| 22 | |||
| 23 | |||
| 24 | 1 | 1; | |
| 25 | |||
| 26 | __END__ | ||
| 27 | |||
| 28 | =pod | ||
| 29 | |||
| 30 | =encoding UTF-8 | ||
| 31 | |||
| 32 | =head1 NAME | ||
| 33 | |||
| 34 | DBIO::MSSQL::SQLMaker - MSSQL-specific SQL generation for DBIO | ||
| 35 | |||
| 36 | =head1 VERSION | ||
| 37 | |||
| 38 | version 0.900001 | ||
| 39 | |||
| 40 | =head1 DESCRIPTION | ||
| 41 | |||
| 42 | L<DBIO::SQLMaker> subclass for Microsoft SQL Server. Implements LIMIT/OFFSET | ||
| 43 | via C<ROW_NUMBER() OVER()> (the dialect SQL Server 2005+ supports) and | ||
| 44 | overrides the default C<OVER()> order expression to use C<(SELECT(1))> | ||
| 45 | because MSSQL does not support an empty C<OVER()> clause. | ||
| 46 | |||
| 47 | Used automatically by L<DBIO::MSSQL::Storage>. | ||
| 48 | |||
| 49 | =head1 METHODS | ||
| 50 | |||
| 51 | =head2 apply_limit | ||
| 52 | |||
| 53 | my $sql = $sqlmaker->apply_limit($sql, $rs_attrs, $rows, $offset); | ||
| 54 | |||
| 55 | MSSQL has no C<LIMIT>/C<OFFSET> keyword (before 2012's C<OFFSET ... FETCH>). | ||
| 56 | DBIO targets the broadly compatible C<ROW_NUMBER() OVER()> windowing | ||
| 57 | dialect: the query is wrapped in a derived table that numbers rows, then | ||
| 58 | sliced by C<WHERE rno BETWEEN offset+1 AND offset+rows>. Replaces the | ||
| 59 | DBIx::Class C<sql_limit_dialect> string dispatch. | ||
| 60 | |||
| 61 | =head1 SEE ALSO | ||
| 62 | |||
| 63 | =over | ||
| 64 | |||
| 65 | =item * L<DBIO::MSSQL::Storage> - MSSQL storage (uses this SQL maker) | ||
| 66 | |||
| 67 | =item * L<DBIO::SQLMaker> - Base SQL maker class | ||
| 68 | |||
| 69 | =back | ||
| 70 | |||
| 71 | =head1 AUTHOR | ||
| 72 | |||
| 73 | DBIO & DBIx::Class Authors | ||
| 74 | |||
| 75 | =head1 COPYRIGHT AND LICENSE | ||
| 76 | |||
| 77 | Copyright (C) 2026 DBIO Authors | ||
| 78 | Portions Copyright (C) 2005-2025 DBIx::Class Authors | ||
| 79 | Based on DBIx::Class, heavily modified. | ||
| 80 | |||
| 81 | This is free software; you can redistribute it and/or modify it under | ||
| 82 | the same terms as the Perl 5 programming language system itself. | ||
| 83 | |||
| 84 | =cut | ||