lib/sequel/adapters/tinytds.rb in sequel-3.29.0 vs lib/sequel/adapters/tinytds.rb in sequel-3.30.0
- old
+ new
@@ -184,46 +184,50 @@
private
# Run execute_select on the database with the given SQL and the stored
# bind arguments.
def execute(sql, opts={}, &block)
- super(sql, {:arguments=>bind_arguments}.merge(opts), &block)
+ super(prepared_sql, {:arguments=>bind_arguments}.merge(opts), &block)
end
# Same as execute, explicit due to intricacies of alias and super.
def execute_dui(sql, opts={}, &block)
- super(sql, {:arguments=>bind_arguments}.merge(opts), &block)
+ super(prepared_sql, {:arguments=>bind_arguments}.merge(opts), &block)
end
# Same as execute, explicit due to intricacies of alias and super.
def execute_insert(sql, opts={}, &block)
- super(sql, {:arguments=>bind_arguments}.merge(opts), &block)
+ super(prepared_sql, {:arguments=>bind_arguments}.merge(opts), &block)
end
end
# 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 db.timezone == :utc
- rn = row_number_column if @opts[:offset]
+ rn = row_number_column if offset = @opts[:offset]
columns = cols = result.fields.map{|c| output_identifier(c)}
- if opts[:offset]
+ if offset
rn = row_number_column
columns = columns.dup
columns.delete(rn)
end
@columns = columns
- if identifier_output_method
+ #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(rn) if rn
yield h
end
+=begin
+ # Temporarily disable this optimization, as tiny_tds uses string keys
+ # if result.fields is called before result.each(:symbolize_keys=>true).
+ # See https://github.com/rails-sqlserver/tiny_tds/issues/57
else
each_opts[:symbolize_keys] = true
if offset
result.each(each_opts) do |r|
r.delete(rn) if rn
@@ -231,10 +235,11 @@
end
else
result.each(each_opts, &Proc.new)
end
end
+=end
end
self
end
# Create a named prepared statement that is stored in the
@@ -250,11 +255,12 @@
end
private
# Properly escape the given string +v+.
- def literal_string(v)
- s = db.synchronize{|c| "#{'N' if mssql_unicode_strings}'#{c.escape(v)}'"}
+ def literal_string_append(sql, v)
+ sql << 'N' if mssql_unicode_strings
+ sql << "'" << db.synchronize{|c| c.escape(v)} << "'"
end
end
end
end