Class Index [+]

Quicksearch

Sequel::DataObjects::Database

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.

Constants

DISCONNECT_ERROR_RE

Public Class Methods

new(opts) click to toggle source

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

Public Instance Methods

connect(server) click to toggle source

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(sql, opts={}) click to toggle source

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_dui(sql, opts={}) click to toggle source

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_insert(sql, opts={}) click to toggle source

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
subadapter() click to toggle source

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
uri(opts={}) click to toggle source

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

Private Instance Methods

connection_execute_method() click to toggle source

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
database_error_classes() click to toggle source

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
disconnect_connection(c) click to toggle source

Close the given database connection.

     # File lib/sequel/adapters/do.rb, line 130
130:       def disconnect_connection(c)
131:         c.close
132:       end
disconnect_error?(e, opts) click to toggle source

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
log_connection_execute(conn, sql) click to toggle source

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
setup_connection(conn) click to toggle source

Allow extending the given connection when it is first created. By default, just returns the connection.

     # File lib/sequel/adapters/do.rb, line 146
146:       def setup_connection(conn)
147:         conn
148:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.