spec/db/schema.rb in goldiloader-0.0.4 vs spec/db/schema.rb in goldiloader-0.0.5
- old
+ new
@@ -65,21 +65,31 @@
has_many :read_only_posts, -> { readonly }, class_name: 'Post'
has_many :limited_posts, -> { limit(2) }, class_name: 'Post'
has_many :grouped_posts, -> { group(:blog_id) }, class_name: 'Post'
has_many :offset_posts, -> { offset(2) }, class_name: 'Post'
has_many :from_posts, -> { from('(select distinct blog_id from posts) as posts') }, class_name: 'Post'
+
+ has_many :posts_ordered_by_author, -> { joins(:author).order('users.name') }, class_name: 'Post'
+
+ has_many :authors_with_join, -> { joins(:address).order('addresses.city') }, through: :posts, source: :author
else
has_many :read_only_posts, readonly: true, class_name: 'Post'
has_many :limited_posts, limit: 2, class_name: 'Post'
has_many :grouped_posts, group: :blog_id, class_name: 'Post'
has_many :offset_posts, offset: 2, class_name: 'Post'
- has_many :from_posts, finder_sql: Proc.new { "select distinct blog_id from posts where blog_id = #{self.id}" },
+
+ has_many :posts_ordered_by_author, include: :author, order: 'users.name', class_name: 'Post'
+ end
+
+ if Goldiloader::Compatibility.association_finder_sql_enabled?
+ has_many :finder_sql_posts, finder_sql: Proc.new { "select distinct blog_id from posts where blog_id = #{self.id}" },
class_name: 'Post'
end
has_many :posts_overridden, class_name: 'Post'
has_many :authors, through: :posts
+ has_many :addresses, through: :authors
if Goldiloader::Compatibility.mass_assignment_security_enabled?
attr_accessible :name
end
@@ -116,15 +126,29 @@
has_many :posts, foreign_key: :author_id
has_many :tags, as: :owner
has_one :address
has_one :address_without_auto_include, auto_include: false, class_name: 'Address'
+ if Goldiloader::Compatibility.unscope_query_method_enabled?
+ has_one :scoped_address_with_default_scope_remove, -> { unscope(where: :city) }, class_name: 'ScopedAddress'
+ end
+
if Goldiloader::Compatibility.mass_assignment_security_enabled?
attr_accessible :name
end
end
class Address < ActiveRecord::Base
+ belongs_to :user
+
+ if Goldiloader::Compatibility.mass_assignment_security_enabled?
+ attr_accessible :city
+ end
+end
+
+class ScopedAddress < ActiveRecord::Base
+ self.table_name = 'addresses'
+ default_scope { where(city: ['Philadelphia'])}
belongs_to :user
if Goldiloader::Compatibility.mass_assignment_security_enabled?
attr_accessible :city
end