lib/partitioned/partitioned_base/sql_adapter.rb in partitioned-1.1.3 vs lib/partitioned/partitioned_base/sql_adapter.rb in partitioned-1.1.5

- old
+ new

@@ -91,11 +91,11 @@ # # Override this or order the tables from last (greatest value? greatest date?) to first. # def last_n_partitions_order_by_clause - return configurator.last_n_partitions_order_by_clause + return configurator.last_partitions_order_by_clause end # # Used to create the parent table rule to ensure. # @@ -108,14 +108,14 @@ ensure_always_fail_on_insert_exists insert_redirector_name = parent_table_rule_name("insert", "redirector", *partition_key_values) sql = <<-SQL CREATE OR REPLACE RULE #{insert_redirector_name} AS - ON INSERT TO #{configurator.parent_table_name(*partition_key_values)} + ON INSERT TO #{configurator.table_name(*partition_key_values)} DO INSTEAD ( - SELECT always_fail_on_insert('#{configurator.parent_table_name(*partition_key_values)}') + SELECT always_fail_on_insert('#{configurator.table_name(*partition_key_values)}') ) SQL execute(sql) end @@ -139,11 +139,12 @@ def create_partition_table(*partition_key_values) create_table(configurator.table_name(*partition_key_values), { :id => false, :options => "INHERITS (#{configurator.parent_table_name(*partition_key_values)})" }) do |t| - t.check_constraint configurator.check_constraint(*partition_key_values) + constraint = configurator.check_constraint(*partition_key_values) + t.check_constraint constraint if constraint end end # # Remove a specific single child table. @@ -169,10 +170,10 @@ # # Used when creating the name of a SQL rule. # def parent_table_rule_name(name, suffix = "rule", *partition_key_values) - return "#{configurator.parent_table_name(*partition_key_values).gsub(/[.]/, '_')}_#{name}_#{suffix}" + return "#{configurator.table_name(*partition_key_values).gsub(/[.]/, '_')}_#{name}_#{suffix}" end # # Used to create index names. #