DataObjects uses it’s own internal connection pooling in addition to the pooling that Sequel uses. You should make sure that you don’t set the connection pool size to more than 8 for a Sequel::DataObjects::Database object, or hack DataObjects (or Extlib) to use a pool size at least as large as the pool size being used by Sequel.
Call the DATABASE_SETUP proc directly after initialization, so the object always uses sub adapter specific code. Also, raise an error immediately if the connection doesn’t have a uri, since DataObjects requires one.
# File lib/sequel/adapters/do.rb, line 51 51: def initialize(opts) 52: super 53: raise(Error, "No connection string specified") unless uri 54: if prok = DATABASE_SETUP[subadapter.to_sym] 55: prok.call(self) 56: end 57: end
Setup a DataObjects::Connection to the database.
# File lib/sequel/adapters/do.rb, line 60 60: def connect(server) 61: setup_connection(::DataObjects::Connection.new(uri(server_opts(server)))) 62: end
Execute the given SQL. If a block is given, the DataObjects::Reader created is yielded to it. A block should not be provided unless a a SELECT statement is being used (or something else that returns rows). Otherwise, the return value is the insert id if opts[:type] is :insert, or the number of affected rows, otherwise.
# File lib/sequel/adapters/do.rb, line 69 69: def execute(sql, opts={}) 70: synchronize(opts[:server]) do |conn| 71: begin 72: command = conn.create_command(sql) 73: res = log_yield(sql){block_given? ? command.execute_reader : command.execute_non_query} 74: rescue ::DataObjects::Error => e 75: raise_error(e) 76: end 77: if block_given? 78: begin 79: yield(res) 80: ensure 81: res.close if res 82: end 83: elsif opts[:type] == :insert 84: res.insert_id 85: else 86: res.affected_rows 87: end 88: end 89: end
Execute the SQL on the this database, returning the number of affected rows.
# File lib/sequel/adapters/do.rb, line 93 93: def execute_dui(sql, opts={}) 94: execute(sql, opts) 95: end
Execute the SQL on this database, returning the primary key of the table being inserted to.
# File lib/sequel/adapters/do.rb, line 99 99: def execute_insert(sql, opts={}) 100: execute(sql, opts.merge(:type=>:insert)) 101: end
Return the subadapter type for this database, i.e. sqlite3 for do:sqlite3::memory:.
# File lib/sequel/adapters/do.rb, line 105 105: def subadapter 106: uri.split(":").first 107: end
Return the DataObjects URI for the Sequel URI, removing the do: prefix.
# File lib/sequel/adapters/do.rb, line 111 111: def uri(opts={}) 112: opts = @opts.merge(opts) 113: (opts[:uri] || opts[:url]).sub(/\Ado:/, '') 114: end
Method to call on a statement object to execute SQL that does not return any rows.
# File lib/sequel/adapters/do.rb, line 120 120: def connection_execute_method 121: :execute_non_query 122: end
dataobjects uses the DataObjects::Error class as the main error class.
# File lib/sequel/adapters/do.rb, line 125 125: def database_error_classes 126: [::DataObjects::Error] 127: end
Close the given database connection.
# File lib/sequel/adapters/do.rb, line 130 130: def disconnect_connection(c) 131: c.close 132: end
Recognize DataObjects::ConnectionError instances as disconnect errors.
# File lib/sequel/adapters/do.rb, line 135 135: def disconnect_error?(e, opts) 136: super || (e.is_a?(::DataObjects::Error) && (e.is_a?(::DataObjects::ConnectionError) || e.message =~ DISCONNECT_ERROR_RE)) 137: end
Execute SQL on the connection by creating a command first
# File lib/sequel/adapters/do.rb, line 140 140: def log_connection_execute(conn, sql) 141: log_yield(sql){conn.create_command(sql).execute_non_query} 142: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.