lib/partitioned/partitioned_base.rb in partitioned-1.1.1 vs lib/partitioned/partitioned_base.rb in partitioned-1.1.3

- old
+ new

@@ -1,8 +1,9 @@ # # :include: ../../README # +require "bulk_data_methods" module Partitioned # # Used by PartitionedBase class methods that must be overridden. # @@ -17,20 +18,20 @@ # an ActiveRecord::Base class that can be partitioned. # # Uses a domain specific language to configure, see Partitioned::PartitionedBase::Configurator # for more information. # - # Extends Partitioned::BulkMethodsMixin to provide create_many and update_many. + # Extends BulkMethodsMixin to provide create_many and update_many. # # Uses PartitionManager to manage creation of child tables. # # Monkey patches some ActiveRecord routines to call back to this class when INSERT and UPDATE # statements are built (to determine the table_name with respect to values being inserted or updated) # class PartitionedBase < ActiveRecord::Base include ActiveRecordOverrides - extend Partitioned::BulkMethodsMixin + extend ::BulkMethodsMixin self.abstract_class = true # # Returns an array of attribute names (strings) used to fetch the key value(s) @@ -159,11 +160,11 @@ # active record find() to a specific child table. Is probably best used in advanced # activerecord queries when a number of tables are involved in the query. # # Use as: # - # Foo.from_partitioned_without_alias(KEY).find(:all, :select => "*") + # Foo.from_partition_without_alias(KEY).find(:all, :select => "*") # # where KEY is the key value(s) used as the check constraint on Foo's table. # # it's not obvious why :select => "*" is supplied. note activerecord wants # to use the name of parent table for access to any attributes, so without @@ -172,16 +173,12 @@ # SELECT foos.* FROM foos_partitions.pXXX # # which fails because table foos is not referenced. using the form #from_partition # is almost always the correct thing when using activerecord. # - # Because the scope is specific to a class (a class method) but unlike - # class methods is not inherited, one must use this form (#from_partitioned_without_alias) instead - # of #from_partitioned_without_alias_scope to get the most derived classes specific active record scope. - # # @param [*Array<Object>] partition_field the field values to partition on # @return [Hash] the scoping - def self.from_partitioned_without_alias(*partition_field) + def self.from_partition_without_alias(*partition_field) table_alias_name = partition_table_name(*partition_field) from(table_alias_name). tap{|relation| relation.table.table_alias = table_alias_name} end