Permalink
Browse files

merged our patch with jeremy's

  • Loading branch information...
1 parent ec30897 commit 3b9590d899e5cb486b57dcab610ceb8fbfd25185 Nusco+Beppe committed Jul 29, 2008
Showing with 4 additions and 65 deletions.
  1. +0 −58 lib/sequel_core/adapters/ado.rb
  2. +4 −7 lib/sequel_core/adapters/shared/mssql.rb
@@ -43,64 +43,6 @@ def execute(sql)
end
class Dataset < Sequel::Dataset
- def select_sql(opts = nil)
- opts = opts ? @opts.merge(opts) : @opts
-
- if sql = opts[:sql]
- return sql
- end
-
- # ADD TOP to SELECT string for LIMITS
- if limit = opts[:limit]
- top = "TOP #{limit} "
- raise Error, "Offset not supported" if opts[:offset]
- end
-
- columns = opts[:select]
- select_columns = columns ? column_list(columns) : WILDCARD
-
- if distinct = opts[:distinct]
- distinct_clause = distinct.empty? ? "DISTINCT" : "DISTINCT ON (#{expression_list(distinct)})"
- sql = "SELECT #{top}#{distinct_clause} #{select_columns}"
- else
- sql = "SELECT #{top}#{select_columns}"
- end
-
- if opts[:from]
- sql << " FROM #{source_list(opts[:from])}"
- end
-
- if join = opts[:join]
- join.each{|j| sql << literal(j)}
- end
-
- if where = opts[:where]
- sql << " WHERE #{literal(where)}"
- end
-
- if group = opts[:group]
- sql << " GROUP BY #{expression_list(group)}"
- end
-
- if having = opts[:having]
- sql << " HAVING #{literal(having)}"
- end
-
- if order = opts[:order]
- sql << " ORDER BY #{expression_list(order)}"
- end
-
- if union = opts[:union]
- sql << (opts[:union_all] ? \
- " UNION ALL #{union.sql}" : " UNION #{union.sql}")
- end
-
- raise Error, "Intersect not supported" if opts[:intersect]
- raise Error, "Except not supported" if opts[:except]
-
- sql
- end
-
def literal(v)
case v
when Time
@@ -90,14 +90,11 @@ def select_sql(opts = nil)
if union = opts[:union]
sql << (opts[:union_all] ? \
" UNION ALL #{union.sql}" : " UNION #{union.sql}")
- elsif intersect = opts[:intersect]
- sql << (opts[:intersect_all] ? \
- " INTERSECT ALL #{intersect.sql}" : " INTERSECT #{intersect.sql}")
- elsif except = opts[:except]
- sql << (opts[:except_all] ? \
- " EXCEPT ALL #{except.sql}" : " EXCEPT #{except.sql}")
end
-
+
+ raise Error, "Intersect not supported" if opts[:intersect]
+ raise Error, "Except not supported" if opts[:except]
+
sql
end
alias_method :sql, :select_sql

0 comments on commit 3b9590d

Please sign in to comment.