Class: Sequel::Mysql2::Dataset

Inherits:
Dataset
  • Object
show all
Includes:
Sequel::MySQL::DatasetMethods, Sequel::MySQL::MysqlMysql2::DatasetMethods, Sequel::MySQL::PreparedStatements::DatasetMethods
Defined in:
lib/sequel/adapters/mysql2.rb

Constant Summary collapse

STREAMING_SUPPORTED =
::Mysql2::VERSION >= '0.3.12'
PreparedStatementMethods =
prepared_statements_module(
"sql = self; opts = Hash[opts]; opts[:arguments] = bind_arguments",
Sequel::Dataset::UnnumberedArgumentMapper,
%w"execute execute_dui execute_insert")

Constants included from Sequel::MySQL::MysqlMysql2::DatasetMethods

Sequel::MySQL::MysqlMysql2::DatasetMethods::StoredProcedureMethods

Constants included from Sequel::MySQL::DatasetMethods

Sequel::MySQL::DatasetMethods::MATCH_AGAINST, Sequel::MySQL::DatasetMethods::MATCH_AGAINST_BOOLEAN

Instance Method Summary collapse

Methods included from Dataset::StoredProcedures

#call_sproc, #prepare_sproc

Methods included from Sequel::MySQL::DatasetMethods

#calc_found_rows, #complex_expression_sql_append, #constant_sql_append, #delete_from, #distinct, #explain, #for_share, #full_text_search, #full_text_sql, #insert_ignore, #insert_select, #insert_select_sql, #on_duplicate_key_update, #quoted_identifier_append, #supports_cte?, #supports_derived_column_lists?, #supports_distinct_on?, #supports_group_rollup?, #supports_intersect_except?, #supports_limits_in_correlated_subqueries?, #supports_modifying_joins?, #supports_nowait?, #supports_ordered_distinct_on?, #supports_regexp?, #supports_returning?, #supports_skip_locked?, #supports_timestamp_usecs?, #supports_window_clause?, #supports_window_functions?, #update_ignore

Methods included from Dataset::Replace

#multi_replace, #replace, #replace_sql, #supports_replace?

Instance Method Details

#fetch_rows(sql) ⇒ Object



247
248
249
250
251
252
253
# File 'lib/sequel/adapters/mysql2.rb', line 247

def fetch_rows(sql)
  execute(sql) do |r|
    self.columns = r.fields.map!{|c| output_identifier(c.to_s)}
    r.each(:cast_booleans=>convert_tinyint_to_bool?){|h| yield h}
  end
  self
end

#paged_each(opts = OPTS, &block) ⇒ Object

Use streaming to implement paging if Mysql2 supports it and it hasn't been disabled.



257
258
259
260
261
262
263
264
265
266
# File 'lib/sequel/adapters/mysql2.rb', line 257

def paged_each(opts=OPTS, &block)
  if STREAMING_SUPPORTED && opts[:stream] != false
    unless defined?(yield)
      return enum_for(:paged_each, opts)
    end
    stream.each(&block)
  else
    super
  end
end

#streamObject

Return a clone of the dataset that will stream rows when iterating over the result set, so it can handle large datasets that won't fit in memory (Requires mysql 0.3.12+ to have an effect).



271
272
273
# File 'lib/sequel/adapters/mysql2.rb', line 271

def stream
  clone(:stream=>true)
end