| Path: | doc/release_notes/3.33.0.txt |
| Last Update: | Thu Jun 06 17:01:31 +0000 2013 |
Sequel.extension :server_block
DB.extend Sequel::ServerBlock
DB.with_server(:shard_1) do
# All of these will execute against shard_1
DB.tables
DB[:table].all
DB.run 'SOME SQL'
end
Sequel.extension :arbitrary_servers DB.pool.extend Sequel::ArbitraryServers DB[:table].server(:host=>'foo', :database=>'bar').all
You can use this extension in conjunction with the server_block extension:
DB.with_server(:host=>'foo', :database=>'bar') do
DB.synchronize do
# All of these will execute on host foo, database bar
DB.tables
DB[:table].all
DB.run 'SOME SQL'
end
end
The combination of these two extensions makes it pretty easy to write a thread-safe Rack middleware that scopes each request to an arbitrary database.
DB[:table].update(:boolean_column=>{'t'=>1}.
case(0, :boolean_column))
The integer_booleans default setting may change in a future version of Sequel, so you should set it manually to false if you prefer the current default.
The first way to disable transactions is on a per-migration basis by calling the no_transaction method inside the Sequel.migration block:
Sequel.migration do
no_transaction
change do
# ...
end
end
That will make it so that a transaction is not used for that particular migration. The second way is passing the :use_tranctions=>false option when calling Migrator.run (using the API), which will completely disable transactions for all migrations during the migrator run.
Any custom type conversion procs used with the sqlite adapter should be modified to work with Integer/Float objects in addition to String objects.