Do not use 2**32 directly - causes %u differences between 32 and 64bit
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / SQLAHacks.pm
index cd086c4..500ce54 100644 (file)
@@ -33,6 +33,9 @@ BEGIN {
   }
 }
 
+# the "oh noes offset/top without limit" constant
+sub __max_int { 0xFFFFFFFF };
+
 
 # Tries to determine limit dialect.
 #
@@ -392,6 +395,21 @@ sub _Top {
   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