Class | Sequel::MySQL::Dataset
In: | lib/sequel/adapters/mysql.rb
Parent: | Sequel::Dataset

Dataset class for MySQL datasets accessed via the native driver.

### Methods

call delete fetch_rows insert prepare replace update

### Included Modules

Sequel::MySQL::DatasetMethods StoredProcedures

### Classes and Modules

Module Sequel::MySQL::Dataset::CallableStatementMethods
Module Sequel::MySQL::Dataset::PreparedStatementMethods
Module Sequel::MySQL::Dataset::StoredProcedureMethods

### Public Instance methods

call(type, bind_arguments={}, values=nil)

MySQL is different in that it supports prepared statements but not bound variables outside of prepared statements. The default implementation breaks the use of subselects in prepared statements, so extend the temporary prepared statement that this creates with a module that fixes it.

[Source]

         # File lib/sequel/adapters/mysql.rb, line 289
    289:       def call(type, bind_arguments={}, values=nil)
    290:         ps = to_prepared_statement(type, values)
    291:         ps.extend(CallableStatementMethods)
    292:         ps.call(bind_arguments)
    293:       end

delete()

Delete rows matching this dataset

[Source]

         # File lib/sequel/adapters/mysql.rb, line 296
    296:       def delete
    297:         execute_dui(delete_sql){|c| c.affected_rows}
    298:       end

fetch_rows(sql) {|h| ...}

Yield all rows matching this dataset

[Source]

         # File lib/sequel/adapters/mysql.rb, line 301
    301:       def fetch_rows(sql)
    302:         execute(sql) do |r|
    303:           column_types = []
    304:           @columns = r.fetch_fields.map{|f| column_types << f.type; output_identifier(f.name)}
    305:           while row = r.fetch_row
    306:             h = {}
    307:             @columns.each_with_index {|f, i| h[f] = convert_type(row[i], column_types[i])}
    308:             yield h
    309:           end
    310:         end
    311:         self
    312:       end

insert(*values)

Insert a new value into this dataset

[Source]

         # File lib/sequel/adapters/mysql.rb, line 315
    315:       def insert(*values)
    316:         execute_dui(insert_sql(*values)){|c| c.insert_id}
    317:       end

prepare(type, name=nil, values=nil)

Store the given type of prepared statement in the associated database with the given name.

[Source]

         # File lib/sequel/adapters/mysql.rb, line 321
    321:       def prepare(type, name=nil, values=nil)
    322:         ps = to_prepared_statement(type, values)
    323:         ps.extend(PreparedStatementMethods)
    324:         if name
    325:           ps.prepared_statement_name = name
    326:           db.prepared_statements[name] = ps
    327:         end
    328:         ps
    329:       end

replace(*args)

Replace (update or insert) the matching row.

[Source]

         # File lib/sequel/adapters/mysql.rb, line 332
    332:       def replace(*args)
    333:         execute_dui(replace_sql(*args)){|c| c.insert_id}
    334:       end

update(values={})

Update the matching rows.

[Source]

         # File lib/sequel/adapters/mysql.rb, line 337
    337:       def update(values={})
    338:         execute_dui(update_sql(values)){|c| c.affected_rows}
    339:       end

[Validate]