Permalink
Browse files

Revert "Add readonly support for relations."

This reverts commit 7cce95b.
  • Loading branch information...
miloops committed Aug 27, 2009
1 parent 7cce95b commit f2c0725d79e29b02e30e7a4827851acc4a766730
@@ -1722,19 +1722,14 @@ def default_select(qualified)
def construct_finder_arel(options = {}, scope = scope(:find))
# TODO add lock to Arel
- relation = arel_table(options[:from]).
+ arel_table(options[:from]).
joins(construct_join(options[:joins], scope)).
conditions(construct_conditions(options[:conditions], scope)).
select(options[:select] || (scope && scope[:select]) || default_select(options[:joins] || (scope && scope[:joins]))).
group(construct_group(options[:group], options[:having], scope)).
order(construct_order(options[:order], scope)).
limit(construct_limit(options[:limit], scope)).
offset(construct_offset(options[:offset], scope))
-
- relation = relation.readonly if options[:readonly]
-
- relation
-
end
def construct_finder_sql(options, scope = scope(:find))
@@ -5,20 +5,10 @@ class Relation
def initialize(klass, relation)
@klass, @relation = klass, relation
- @readonly = false
- end
-
- def readonly
- @readonly = true
- self
end
def to_a
- records = @klass.find_by_sql(@relation.to_sql)
-
- records.each { |record| record.readonly! } if @readonly
-
- records
+ @klass.find_by_sql(@relation.to_sql)
end
def each(&block)
@@ -79,11 +79,5 @@ def test_relation_responds_to_delegated_methods
assert relation.respond_to?(method)
end
end
-
- def test_find_with_readonly_option
- Developer.all.each { |d| assert !d.readonly? }
- Developer.all.readonly.each { |d| assert d.readonly? }
- Developer.all(:readonly => true).each { |d| assert d.readonly? }
- end
end

0 comments on commit f2c0725

Please sign in to comment.