lib/sequel/plugins/pg_array_associations.rb in sequel-4.43.0 vs lib/sequel/plugins/pg_array_associations.rb in sequel-4.44.0
- old
+ new
@@ -73,11 +73,11 @@
# This plugin requires that the underlying database have the pg_array
# extension loaded.
module PgArrayAssociations
# The AssociationReflection subclass for many_to_pg_array associations.
class ManyToPgArrayAssociationReflection < Sequel::Model::Associations::AssociationReflection
- Sequel::Model::Associations::ASSOCIATION_TYPES[:many_to_pg_array] = self
+ Sequel.synchronize{Sequel::Model::Associations::ASSOCIATION_TYPES[:many_to_pg_array] = self}
def array_type
cached_fetch(:array_type) do
if (sch = associated_class.db_schema) && (s = sch[self[:key]]) && (t = s[:db_type])
t
@@ -120,10 +120,17 @@
# Don't use a filter by associations limit strategy
def filter_by_associations_limit_strategy
nil
end
+ FINALIZE_SETTINGS = superclass::FINALIZE_SETTINGS.merge(
+ :array_type=>:array_type
+ ).freeze
+ def finalize_settings
+ FINALIZE_SETTINGS
+ end
+
# Handle silent failure of add/remove methods if raise_on_save_failure is false.
def handle_silent_modification_failure?
self[:raise_on_save_failure] == false
end
@@ -175,11 +182,11 @@
end
end
# The AssociationReflection subclass for pg_array_to_many associations.
class PgArrayToManyAssociationReflection < Sequel::Model::Associations::AssociationReflection
- Sequel::Model::Associations::ASSOCIATION_TYPES[:pg_array_to_many] = self
+ Sequel.synchronize{Sequel::Model::Associations::ASSOCIATION_TYPES[:pg_array_to_many] = self}
def array_type
cached_fetch(:array_type) do
if (sch = self[:model].db_schema) && (s = sch[self[:key]]) && (t = s[:db_type])
t
@@ -225,9 +232,18 @@
end
# Don't use a filter by associations limit strategy
def filter_by_associations_limit_strategy
nil
+ end
+
+ FINALIZE_SETTINGS = superclass::FINALIZE_SETTINGS.merge(
+ :array_type=>:array_type,
+ :primary_key=>:primary_key,
+ :primary_key_method=>:primary_key_method
+ ).freeze
+ def finalize_settings
+ FINALIZE_SETTINGS
end
# Handle silent failure of add/remove methods if raise_on_save_failure is false
# and save_after_modify is true.
def handle_silent_modification_failure?