balinterdi / activerecord-do-adapter

ActiveRecord DataObjects adapter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

activerecord-do-adapter

DESCRIPTION:

This is ActiveRecord DataObjects adapter. It uses DataObjects drivers to access database. Currently MySQL DataObjects adapter is created.

USAGE / FEATURES:

In database.yml just replace e.g. “mysql” with “do_mysql”

DataObjects MySQL adapter differences from original MySQL adapter:

  • _before_type_cast return already corresponding Ruby type for table column (e.g. Fixnum, Float, DateTime, String …) and not always String, as original adapter

  • calculation results (e.g. SUM(column) or COUNT(*)) are returned as numeric results and not strings

  • table and column name quoting is done with double quotes and not backquotes

  • connection.exec cannot be done with SELECT statements

  • auto reconnection is turned on by default and cannot be turned off

TODO / PROBLEMS:

  • Extlib pluralization is overwriting ActiveSupport pluralization and is not compatible with it - currently there is workaround which loads ActiveSupport one more time, need to change DataObjects not to require Extlib pluralization

  • need to investigate how to pass bind parameters from ActiveRecord to adapter

HOW TO RUN TESTS:

DataObjects adapter has some initial set of RSpec tests which can help to get basic adapter functionality to be implemented. After that it is supposed that ActiveRecord unit tests will be run.

To run ActiveRecord unit tests

  • clone git://github.com/rails/rails.git in the same parent directory where you have this repository (meaning that ../rails/activerecord should point to ActiveRecord base directory)

  • see ../rails/activerecord/RUNNING_UNIT_TESTS about how to setup test databases

  • run basic adapter tests:

    rake test_mysql TEST=test/cases/adapter_test.rb
    rake test_mysql TEST=test/cases/base_test.rb
    
  • or run all set of tests

    rake test_mysql
    
  • if you need to modify initial test setup then edit test/connections/native_mysql/connection.rb

REQUIREMENTS:

  • data_objects version 0.10.0 and corresponding DataObjects driver gems should be installed

  • now is tested with Ruby 1.8.6, Ruby 1.9.1 and JRuby 1.3.1

INSTALL:

  • git clone git://github.com/rsim/activerecord-do-adapter.git

  • cd activerecord-do-adapter

  • rake install_gem

LICENSE:

(The MIT License)

Copyright © 2009 Raimonds Simanovskis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

ActiveRecord DataObjects adapter