SQL Object is an ORM solution that maps SQL queries onto Ruby objects. It aims to provide an alternative to ActiveRecord.
- SQLite3
- RSpec
- ActiveSupport::Inflector
- Replicates core functionality of ActiveRecord::Base
SQLObject provides a few of your favorite ActiveRecord associations:
has_many
belongs_to
has_one_through
SQLObject provides the following ActiveRecord methods:
#save
#create
#update
#destroy
SQLObject makes reference to DBConnection
, which delegates SQLite::Database
instance methods like #execute
, #get_first_row
, #last_insert_row_id
, etc.
to a singleton instance of SQLite::Database. Consumers of the API specify this
instance by calling DBConnection::open(file)
, providing an SQLite db file path
as an argument.
SQLObject provides a utility belt of class/instance methods that map to SQL queries.
Associations (has_many
, belongs_to
, has_one_through
) are dynamically
generated by the Associatable
module, which extends
SQLObject. Associations infer class_name
, foreign_key
and primary_key
based on the same conventions as ActiveRecord. You can override these if the
database schema you're working with is non-compliant (or ActiveSupport::Inflector fails to guess your table name).