[Bast-commits] r9538 - in DBIx-Class/0.08/trunk/lib/DBIx/Class: .
Storage/DBI/Sybase
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Wed Jun 2 07:03:33 GMT 2010
Author: caelum
Date: 2010-06-02 08:03:33 +0100 (Wed, 02 Jun 2010)
New Revision: 9538
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm
Log:
use SET ROWCOUNT for Sybase ASE limits without an offset
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm 2010-06-02 05:05:39 UTC (rev 9537)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm 2010-06-02 07:03:33 UTC (rev 9538)
@@ -392,6 +392,21 @@
return $sql;
}
+# This for Sybase ASE, to use SET ROWCOUNT when there is no offset, and
+# GenericSubQ otherwise.
+sub _RowCountOrGenericSubQ {
+ my $self = shift;
+ my ($sql, $rs_attrs, $rows, $offset) = @_;
+
+ return $self->_GenericSubQ(@_) if $offset;
+
+ return sprintf <<"EOF", $rows, $sql;
+SET ROWCOUNT %d
+%s
+SET ROWCOUNT 0
+EOF
+}
+
# This is the most evil limit "dialect" (more of a hack) for *really*
# stupid databases. It works by ordering the set by some unique column,
# and calculating amount of rows that have a less-er value (thus
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm 2010-06-02 05:05:39 UTC (rev 9537)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm 2010-06-02 07:03:33 UTC (rev 9538)
@@ -152,6 +152,16 @@
};
}
+sub _sql_maker_opts {
+ my ( $self, $opts ) = @_;
+
+ if ( $opts ) {
+ $self->{_sql_maker_opts} = { %$opts };
+ }
+
+ return { limit_dialect => 'RowCountOrGenericSubQ', %{$self->{_sql_maker_opts}||{}} };
+}
+
sub disconnect {
my $self = shift;
More information about the Bast-commits
mailing list