lib/sequel/adapters/tinytds.rb in sequel-3.28.0 vs lib/sequel/adapters/tinytds.rb in sequel-3.29.0
- old
+ new
@@ -14,15 +14,10 @@
opts[:username] = opts[:user]
set_mssql_unicode_strings
TinyTds::Client.new(opts)
end
- # Return instance of Sequel::TinyTDS::Dataset with the given options.
- def dataset(opts = nil)
- TinyTDS::Dataset.new(self, opts)
- end
-
# Execute the given +sql+ on the server. If the :return option
# is present, its value should be a method symbol that is called
# on the TinyTds::Result object returned from executing the
# +sql+. The value of such a method is returned to the caller.
# Otherwise, if a block is given, it is yielded the result object.
@@ -148,10 +143,12 @@
end
end
class Dataset < Sequel::Dataset
include Sequel::MSSQL::DatasetMethods
+
+ Database::DatasetClass = self
# SQLite already supports named bind arguments, so use directly.
module ArgumentMapper
include Sequel::Dataset::ArgumentMapper
@@ -206,25 +203,31 @@
# Yield hashes with symbol keys, attempting to optimize for
# various cases.
def fetch_rows(sql)
execute(sql) do |result|
each_opts = {:cache_rows=>false}
- each_opts[:timezone] = :utc if Sequel.database_timezone == :utc
- offset = @opts[:offset]
- @columns = cols = result.fields.map{|c| output_identifier(c)}
+ each_opts[:timezone] = :utc if db.timezone == :utc
+ rn = row_number_column if @opts[:offset]
+ columns = cols = result.fields.map{|c| output_identifier(c)}
+ if opts[:offset]
+ rn = row_number_column
+ columns = columns.dup
+ columns.delete(rn)
+ end
+ @columns = columns
if identifier_output_method
each_opts[:as] = :array
result.each(each_opts) do |r|
h = {}
cols.zip(r).each{|k, v| h[k] = v}
- h.delete(row_number_column) if offset
+ h.delete(rn) if rn
yield h
end
else
each_opts[:symbolize_keys] = true
if offset
result.each(each_opts) do |r|
- r.delete(row_number_column) if offset
+ r.delete(rn) if rn
yield r
end
else
result.each(each_opts, &Proc.new)
end