class Sequel::Mysql2::Dataset
Constants
- PreparedStatementMethods
- STREAMING_SUPPORTED
Public Instance Methods
Source
# File lib/sequel/adapters/mysql2.rb 240 def fetch_rows(sql) 241 execute(sql) do |r| 242 self.columns = r.fields.map!{|c| output_identifier(c.to_s)} 243 r.each(:cast_booleans=>convert_tinyint_to_bool?){|h| yield h} 244 end 245 self 246 end
Source
# File lib/sequel/adapters/mysql2.rb 250 def paged_each(opts=OPTS, &block) 251 if STREAMING_SUPPORTED && opts[:stream] != false 252 unless defined?(yield) 253 return enum_for(:paged_each, opts) 254 end 255 stream.each(&block) 256 else 257 super 258 end 259 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 264 def stream 265 clone(:stream=>true) 266 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 285 def bound_variable_modules 286 [PreparedStatementMethods] 287 end
Source
# File lib/sequel/adapters/mysql2.rb 273 def convert_tinyint_to_bool? 274 @db.convert_tinyint_to_bool 275 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 277 def execute(sql, opts=OPTS) 278 opts = Hash[opts] 279 opts[:type] = :select 280 opts[:stream] = @opts[:stream] 281 super 282 end
Calls superclass method
Sequel::Dataset#execute
Source
# File lib/sequel/adapters/mysql2.rb 295 def literal_string_append(sql, v) 296 sql << "'" << db.synchronize(@opts[:server]){|c| c.escape(v)} << "'" 297 end
Handle correct quoting of strings using ::Mysql2::Client#escape.
Source
# File lib/sequel/adapters/mysql2.rb 289 def prepared_statement_modules 290 [PreparedStatementMethods] 291 end