Methods
Public Instance
Constants
CommandTimeout | = | opts[:command_timeout] if opts[:command_timeout] | ||
Provider | = | opts[:provider] if opts[:provider] |
Attributes
conversion_procs | [R] |
Public Instance methods
In addition to the usual database options, the following options have an effect:
:command_timeout |
Sets the time in seconds to wait while attempting to execute a command before cancelling the attempt and generating an error. Specifically, it sets the |
:driver |
The driver to use in the |
:conn_string |
The full |
:provider |
Sets the |
Pay special attention to the :provider option, as without specifying a provider, many things will be broken. The SQLNCLI10 provider appears to work well if you are connecting to Microsoft SQL Server, but it is not the default as that is not always available and would break backwards compatability.
# File lib/sequel/adapters/ado.rb 112 def connect(server) 113 opts = server_opts(server) 114 s = opts[:conn_string] || "driver=#{opts[:driver]};server=#{opts[:host]};database=#{opts[:database]}#{";uid=#{opts[:user]};pwd=#{opts[:password]}" if opts[:user]}" 115 handle = WIN32OLE.new('ADODB.Connection') 116 handle.CommandTimeout = opts[:command_timeout] if opts[:command_timeout] 117 handle.Provider = opts[:provider] if opts[:provider] 118 handle.Open(s) 119 handle 120 end
# File lib/sequel/adapters/ado.rb 122 def disconnect_connection(conn) 123 conn.Close 124 rescue WIN32OLERuntimeError 125 nil 126 end
# File lib/sequel/adapters/ado.rb 159 def execute(sql, opts=OPTS) 160 synchronize(opts[:server]) do |conn| 161 begin 162 r = log_connection_yield(sql, conn){conn.Execute(sql)} 163 begin 164 yield r if defined?(yield) 165 ensure 166 begin 167 r.close 168 rescue ::WIN32OLERuntimeError 169 end 170 end 171 rescue ::WIN32OLERuntimeError => e 172 raise_error(e) 173 end 174 end 175 nil 176 end
Just execute so it doesn’t attempt to return the number of rows modified.
# File lib/sequel/adapters/ado.rb 134 def execute_ddl(sql, opts=OPTS) 135 execute(sql, opts) 136 end
Use pass by reference in WIN32OLE to get the number of affected rows, unless is a provider is in use (since some providers don’t seem to return the number of affected rows, but the default provider appears to).
# File lib/sequel/adapters/ado.rb 147 def execute_dui(sql, opts=OPTS) 148 return super if opts[:provider] 149 synchronize(opts[:server]) do |conn| 150 begin 151 log_connection_yield(sql, conn){conn.Execute(sql, 1)} 152 WIN32OLE::ARGV[1] 153 rescue ::WIN32OLERuntimeError => e 154 raise_error(e) 155 end 156 end 157 end
Just execute so it doesn’t attempt to return the number of rows modified.
# File lib/sequel/adapters/ado.rb 139 def execute_insert(sql, opts=OPTS) 140 execute(sql, opts) 141 end
# File lib/sequel/adapters/ado.rb 128 def freeze 129 @conversion_procs.freeze 130 super 131 end