Skip to content

Commit 5a79fbc

Browse files
author
Gabriel Tadra Mainginski
committed
Now offset works, but it is slow.
1 parent 1d23519 commit 5a79fbc

File tree

1 file changed

+2
-51
lines changed

1 file changed

+2
-51
lines changed

Database/Query/SybaseGrammar.php

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ public function compileSelect(Builder $query)
3434
$this->Builder = $query;
3535
$components = $this->compileComponents($query);
3636

37-
// If an offset is present on the query, we will need to wrap the query in
38-
// a big "ANSI" offset syntax block. This is very nasty compared to the
39-
// other database systems but is necessary for implementing features.
40-
if ($query->offset > 0)
41-
{
42-
abort(501, "Offset function still doesn't work with Sybase. :(");
43-
}
4437
return $this->concatenate($components);
4538
}
4639
/**
@@ -59,7 +52,7 @@ protected function compileColumns(Builder $query, $columns)
5952
// If there is a limit on the query, but not an offset, we will add the top
6053
// clause to the query, which serves as a "limit" type clause within the
6154
// SQL Server system similar to the limit keywords available in MySQL.
62-
if ($query->limit > 0)//&& $query->offset <= 0)
55+
if ($query->limit > 0 && $query->offset <= 0)
6356
{
6457
$select .= 'top '.$query->limit.' ';
6558
}
@@ -87,49 +80,7 @@ protected function compileFrom(Builder $query, $table)
8780

8881
return $from;
8982
}
90-
/**
91-
* Compile the over statement for a table expression.
92-
*
93-
* @param string $orderings
94-
* @return string
95-
*/
96-
protected function compileOver($orderings)
97-
{
98-
return ", row_number() over ({$orderings}) as row_num";
99-
}
100-
101-
/**
102-
* Compile the limit / offset row constraint for a query.
103-
*
104-
* @param \Illuminate\Database\Query\Builder $query
105-
* @return string
106-
*/
107-
protected function compileRowConstraint($query)
108-
{
109-
$start = $query->offset + 1;
110-
111-
if ($query->limit > 0)
112-
{
113-
$finish = $query->offset + $query->limit;
114-
115-
return "between {$start} and {$finish}";
116-
}
117-
118-
return ">= {$start}";
119-
}
120-
121-
/**
122-
* Compile a common table expression for a query.
123-
*
124-
* @param string $sql
125-
* @param string $constraint
126-
* @return string
127-
*/
128-
protected function compileTableExpression($sql, $constraint)
129-
{
130-
return "select * from ({$sql}) as temp_table where row_num {$constraint}";
131-
}
132-
83+
13384
/**
13485
* Compile the "limit" portions of the query.
13586
*

0 commit comments

Comments
 (0)