[ANN] ActiveRecord IO Mode Plugin

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ActiveRecord IO Mode Plugin v.0.0.1


We are pleased to announce the ActiveRecord IO Mode plugin version
0.0.1. It allows you to redirect where sql statements are sent.
By default they are sent to a database connection, with the IO Mode
plugin you can proxy them wherever you want. They can be sent
to any object that responds to the method <<

The link:
http://www.mktec.com/oss/rails-plugins/active_record_io_mode.0.0.1.tgz

Once installed in the vendor/plugins directory you can test this by
running “ruby script/console” from the RAILS_ROOT, and doing something
similar to:

to redirect sql to an array

arr = []
ActiveRecord::Base.send_sql_to arr
=> true

let’s test it

Test.find :all, :limit => 1
=> []
arr
=> [“SELECT * FROM tests LIMIT 1;\n”]

redirect sql back to our db connection

ActiveRecord::Base.send_sql_to :db
=> true
Test.find :all, :limit => 1
=> [#<Test:0x306daef0 @attributes={“name”=>“test1”, “id”=>“1”}>]

Known Limitations


  • it works great with MySQL
  • it should work with PostgreSQL
  • it has not been tested on MSSQL, Oracle, SQLite, etc.

If you can provide feedback for using this with MySQL, MSQQL, Sqlite,
Oracle, PostgreSQL, that would be great!

Any feedback or suggestions are graciously accepted!

Thanks,

Zach D. & Mark Van H.
[email protected] [email protected]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFESAUDMyx0fW1d8G0RAuKoAJ460jcaiKxyd9li50IFVxk3so6IQwCePULg
fYgtb0iasv/xznYokJSSupw=
=AHgV
-----END PGP SIGNATURE-----