3 def add_limit_offset!(sql, options) # :nodoc:
4 @limit = options[:limit]
5 @offset = options[:offset]
7 # Use temp table to hack offset with Sybase
8 sql.sub!(/ FROM /i, ' INTO #artemp FROM ')
10 # "SET ROWCOUNT 0" turns off limits, so we havesy
11 # to use a cheap trick.
13 sql.sub!(/WHERE/i, 'WHERE 1 = 2 AND ')
14 elsif sql =~ /ORDER\s+BY/i
15 sql.sub!(/ORDER\s+BY/i, 'WHERE 1 = 2 ORDER BY')
22 # If limit is not set at all, we can ignore offset;
23 # if limit *is* set but offset is zero, use normal select
24 # with simple SET ROWCOUNT. Thus, only use the temp table
25 # if limit is set and offset > 0.
27 !@limit.nil? && !@offset.nil? && @offset > 0
31 !@limit.nil? && @limit == 0
34 def modify_types(tp) #:nodoc:
35 tp[:primary_key] = "NUMERIC(22,0) IDENTITY PRIMARY KEY"
36 tp[:integer][:limit] = nil
37 tp[:boolean] = {:name => "bit"}
38 tp[:binary] = {:name => "image"}
42 def remove_index(table_name, options = {})
43 execute "DROP INDEX #{table_name}.#{index_name(table_name, options)}"