class Sequel::Mysql2::Dataset
Constants
- PreparedStatementMethods
- STREAMING_SUPPORTED
Public Instance Methods
Source
# File lib/sequel/adapters/mysql2.rb 247 def fetch_rows(sql) 248 execute(sql) do |r| 249 self.columns = r.fields.map!{|c| output_identifier(c.to_s)} 250 r.each(:cast_booleans=>convert_tinyint_to_bool?){|h| yield h} 251 end 252 self 253 end
Source
# File lib/sequel/adapters/mysql2.rb 257 def paged_each(opts=OPTS, &block) 258 if STREAMING_SUPPORTED && opts[:stream] != false 259 unless defined?(yield) 260 return enum_for(:paged_each, opts) 261 end 262 stream.each(&block) 263 else 264 super 265 end 266 end
Use streaming to implement paging if Mysql2
supports it and it hasn’t been disabled.
Calls superclass method
Sequel::Dataset#paged_each
Source
# File lib/sequel/adapters/mysql2.rb 271 def stream 272 clone(:stream=>true) 273 end
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).
Private Instance Methods
Source
# File lib/sequel/adapters/mysql2.rb 292 def bound_variable_modules 293 [PreparedStatementMethods] 294 end
Source
# File lib/sequel/adapters/mysql2.rb 280 def convert_tinyint_to_bool? 281 @db.convert_tinyint_to_bool 282 end
Whether to cast tinyint(1) columns to integer instead of boolean. By default, uses the database’s convert_tinyint_to_bool setting. Exists for compatibility with the mysql adapter.
Source
# File lib/sequel/adapters/mysql2.rb 284 def execute(sql, opts=OPTS) 285 opts = Hash[opts] 286 opts[:type] = :select 287 opts[:stream] = @opts[:stream] 288 super 289 end
Calls superclass method
Sequel::Dataset#execute
Source
# File lib/sequel/adapters/mysql2.rb 302 def literal_string_append(sql, v) 303 sql << "'" << db.synchronize(@opts[:server]){|c| c.escape(v)} << "'" 304 end
Handle correct quoting of strings using ::Mysql2::Client#escape.
Source
# File lib/sequel/adapters/mysql2.rb 296 def prepared_statement_modules 297 [PreparedStatementMethods] 298 end