class Sequel::Mysql2::Dataset
Constants
- PreparedStatementMethods
- STREAMING_SUPPORTED
Public Instance Methods
fetch_rows(sql) { |h| ... }
click to toggle source
# File lib/sequel/adapters/mysql2.rb 236 def fetch_rows(sql) 237 execute(sql) do |r| 238 self.columns = r.fields.map!{|c| output_identifier(c.to_s)} 239 r.each(:cast_booleans=>convert_tinyint_to_bool?){|h| yield h} 240 end 241 self 242 end
paged_each(opts=OPTS, &block)
click to toggle source
Use streaming to implement paging if Mysql2
supports it and it hasn't been disabled.
Calls superclass method
Sequel::Dataset#paged_each
# File lib/sequel/adapters/mysql2.rb 246 def paged_each(opts=OPTS, &block) 247 if STREAMING_SUPPORTED && opts[:stream] != false 248 unless block_given? 249 return enum_for(:paged_each, opts) 250 end 251 stream.each(&block) 252 else 253 super 254 end 255 end
stream()
click to toggle source
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).
# File lib/sequel/adapters/mysql2.rb 260 def stream 261 clone(:stream=>true) 262 end
Private Instance Methods
bound_variable_modules()
click to toggle source
# File lib/sequel/adapters/mysql2.rb 281 def bound_variable_modules 282 [PreparedStatementMethods] 283 end
convert_tinyint_to_bool?()
click to toggle source
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.
# File lib/sequel/adapters/mysql2.rb 269 def convert_tinyint_to_bool? 270 @db.convert_tinyint_to_bool 271 end
execute(sql, opts=OPTS)
click to toggle source
Calls superclass method
Sequel::Dataset#execute
# File lib/sequel/adapters/mysql2.rb 273 def execute(sql, opts=OPTS) 274 opts = Hash[opts] 275 opts[:type] = :select 276 opts[:stream] = @opts[:stream] 277 super 278 end
literal_string_append(sql, v)
click to toggle source
Handle correct quoting of strings using ::Mysql2::Client#escape.
# File lib/sequel/adapters/mysql2.rb 291 def literal_string_append(sql, v) 292 sql << "'" << db.synchronize(@opts[:server]){|c| c.escape(v)} << "'" 293 end
prepared_statement_modules()
click to toggle source
# File lib/sequel/adapters/mysql2.rb 285 def prepared_statement_modules 286 [PreparedStatementMethods] 287 end