mirror of
https://github.com/github/rails.git
synced 2026-01-12 08:08:31 -05:00
Compare commits
4 Commits
kill-build
...
no-interpo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a251e4cf01 | ||
|
|
7562fe1750 | ||
|
|
9a8994da1b | ||
|
|
480c96e422 |
@@ -3072,7 +3072,7 @@ module ActiveRecord #:nodoc:
|
||||
# Interpolate custom SQL string in instance context.
|
||||
# Optional record argument is meant for custom insert_sql.
|
||||
def interpolate_sql(sql, record = nil)
|
||||
instance_eval("%@#{sql.gsub('@', '\@')}@")
|
||||
sql
|
||||
end
|
||||
|
||||
# Initializes the attributes array with keys matching the columns from the linked table and
|
||||
|
||||
@@ -51,13 +51,13 @@ class Firm < Company
|
||||
has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
|
||||
has_many :clients_with_interpolated_conditions, :class_name => "Client", :conditions => 'rating > #{rating}'
|
||||
has_many :clients_like_ms_with_hash_conditions, :conditions => { :name => 'Microsoft' }, :class_name => "Client", :order => "id"
|
||||
has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
|
||||
has_many :clients_using_sql, :class_name => "Client", :finder_sql => proc{"SELECT * FROM companies WHERE client_of = #{id}"}
|
||||
has_many :clients_using_counter_sql, :class_name => "Client",
|
||||
:finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}',
|
||||
:counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = #{id}'
|
||||
:finder_sql => proc{"SELECT * FROM companies WHERE client_of = #{id}"},
|
||||
:counter_sql => proc{"SELECT COUNT(*) FROM companies WHERE client_of = #{id}"}
|
||||
has_many :clients_using_zero_counter_sql, :class_name => "Client",
|
||||
:finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}',
|
||||
:counter_sql => 'SELECT 0 FROM companies WHERE client_of = #{id}'
|
||||
:finder_sql => proc{"SELECT * FROM companies WHERE client_of = #{id}"},
|
||||
:counter_sql => proc{"SELECT 0 FROM companies WHERE client_of = #{id}"}
|
||||
has_many :no_clients_using_counter_sql, :class_name => "Client",
|
||||
:finder_sql => 'SELECT * FROM companies WHERE client_of = 1000',
|
||||
:counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = 1000'
|
||||
|
||||
@@ -7,8 +7,8 @@ class Project < ActiveRecord::Base
|
||||
has_and_belongs_to_many :developers_named_david, :class_name => "Developer", :conditions => "name = 'David'", :uniq => true
|
||||
has_and_belongs_to_many :developers_named_david_with_hash_conditions, :class_name => "Developer", :conditions => { :name => 'David' }, :uniq => true
|
||||
has_and_belongs_to_many :salaried_developers, :class_name => "Developer", :conditions => "salary > 0"
|
||||
has_and_belongs_to_many :developers_with_finder_sql, :class_name => "Developer", :finder_sql => 'SELECT t.*, j.* FROM developers_projects j, developers t WHERE t.id = j.developer_id AND j.project_id = #{id} ORDER BY t.id'
|
||||
has_and_belongs_to_many :developers_by_sql, :class_name => "Developer", :delete_sql => "DELETE FROM developers_projects WHERE project_id = \#{id} AND developer_id = \#{record.id}"
|
||||
has_and_belongs_to_many :developers_with_finder_sql, :class_name => "Developer", :finder_sql => proc{"SELECT t.*, j.* FROM developers_projects j, developers t WHERE t.id = j.developer_id AND j.project_id = #{id} ORDER BY t.id"}
|
||||
has_and_belongs_to_many :developers_by_sql, :class_name => "Developer", :delete_sql => proc{"DELETE FROM developers_projects WHERE project_id = #{id} AND developer_id = #{record.id}"}
|
||||
has_and_belongs_to_many :developers_with_callbacks, :class_name => "Developer", :before_add => Proc.new {|o, r| o.developers_log << "before_adding#{r.id || '<new>'}"},
|
||||
:after_add => Proc.new {|o, r| o.developers_log << "after_adding#{r.id || '<new>'}"},
|
||||
:before_remove => Proc.new {|o, r| o.developers_log << "before_removing#{r.id}"},
|
||||
|
||||
Reference in New Issue
Block a user