diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-04-23 13:01:18 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-04-23 13:01:18 -0300 |
commit | 7978b69948c4fe38911932766d45026467f45e52 (patch) | |
tree | fc410bfe209e1abc98ae2f0cf1247f55efb0471a /lib | |
parent | b29268d5b64bbd7383bfcebc6fcc5e97a657885b (diff) | |
download | rails-7978b69948c4fe38911932766d45026467f45e52.tar.gz rails-7978b69948c4fe38911932766d45026467f45e52.tar.bz2 rails-7978b69948c4fe38911932766d45026467f45e52.zip |
Use the engine not the engine.connection, the engine may not even respond to connection
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/arel.rb | 4 | ||||
-rw-r--r-- | lib/arel/relations/table.rb | 12 | ||||
-rw-r--r-- | lib/arel/session.rb | 22 |
3 files changed, 19 insertions, 19 deletions
diff --git a/lib/arel/arel.rb b/lib/arel/arel.rb index 892be854ee..7780d45e25 100644 --- a/lib/arel/arel.rb +++ b/lib/arel/arel.rb @@ -1,3 +1,3 @@ -def Arel(name, engine = Arel::Table.engine) +def Arel(name, engine = (Arel::Table.engine || ActiveRecord::Base.connection)) Arel::Table.new(name, engine) -end
\ No newline at end of file +end diff --git a/lib/arel/relations/table.rb b/lib/arel/relations/table.rb index 087028fb55..0433abbbb2 100644 --- a/lib/arel/relations/table.rb +++ b/lib/arel/relations/table.rb @@ -3,9 +3,9 @@ module Arel include Recursion::BaseCase cattr_accessor :engine - attr_reader :name, :engine + attr_reader :name, :engine hash_on :name - + def initialize(name, engine = Table.engine) @name, @engine = name.to_s, engine end @@ -19,18 +19,18 @@ module Arel def column_for(attribute) has_attribute?(attribute) and columns.detect { |c| c.name == attribute.name.to_s } end - + def columns @columns ||= engine.columns(name, "#{name} Columns") end - + def reset @attributes = @columns = nil end - + def ==(other) Table === other and name == other.name end end -end
\ No newline at end of file +end diff --git a/lib/arel/session.rb b/lib/arel/session.rb index 8b72fd1fe6..d9a6e4b5e4 100644 --- a/lib/arel/session.rb +++ b/lib/arel/session.rb @@ -1,11 +1,11 @@ require 'singleton' module Arel - class Session + class Session class << self attr_accessor :instance alias_method :manufacture, :new - + def start if @started yield @@ -22,26 +22,26 @@ module Arel end end end - + module CRUD def create(insert) - insert.call(insert.engine.connection) + insert.call(insert.engine) end - + def read(select) (@read ||= Hash.new do |hash, select| - hash[select] = select.call(select.engine.connection) + hash[select] = select.call(select.engine) end)[select] end - + def update(update) - update.call(update.engine.connection) + update.call(update.engine) end - + def delete(delete) - delete.call(delete.engine.connection) + delete.call(delete.engine) end end include CRUD end -end
\ No newline at end of file +end |