From 7ee5ab3d0a87b09733b3e51205736bd6e662a916 Mon Sep 17 00:00:00 2001 From: Joey Marianer Date: Tue, 31 Jul 2018 15:50:01 -0700 Subject: [PATCH 1/4] Use with_connection instead of calling release_connection directly, since the latter may release a connection that belongs to someone else --- lib/closure_tree/has_closure_tree.rb | 32 ++++++++++++++-------------- spec/pool_spec.rb | 5 +++++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/closure_tree/has_closure_tree.rb b/lib/closure_tree/has_closure_tree.rb index b0bc5b1a..6fb47d7a 100644 --- a/lib/closure_tree/has_closure_tree.rb +++ b/lib/closure_tree/has_closure_tree.rb @@ -14,25 +14,25 @@ def has_closure_tree(options = {}) :with_advisory_lock ) - class_attribute :_ct - self._ct = ClosureTree::Support.new(self, options) + connection_pool.with_connection { + class_attribute :_ct + self._ct = ClosureTree::Support.new(self, options) - # Auto-inject the hierarchy table - # See https://github.com/patshaughnessy/class_factory/blob/master/lib/class_factory/class_factory.rb - class_attribute :hierarchy_class - self.hierarchy_class = _ct.hierarchy_class_for_model + # Auto-inject the hierarchy table + # See https://github.com/patshaughnessy/class_factory/blob/master/lib/class_factory/class_factory.rb + class_attribute :hierarchy_class + self.hierarchy_class = _ct.hierarchy_class_for_model - # tests fail if you include Model before HierarchyMaintenance wtf - include ClosureTree::HierarchyMaintenance - include ClosureTree::Model - include ClosureTree::Finders - include ClosureTree::HashTree - include ClosureTree::Digraphs + # tests fail if you include Model before HierarchyMaintenance wtf + include ClosureTree::HierarchyMaintenance + include ClosureTree::Model + include ClosureTree::Finders + include ClosureTree::HashTree + include ClosureTree::Digraphs - include ClosureTree::DeterministicOrdering if _ct.order_option? - include ClosureTree::NumericDeterministicOrdering if _ct.order_is_numeric? - - connection_pool.release_connection + include ClosureTree::DeterministicOrdering if _ct.order_option? + include ClosureTree::NumericDeterministicOrdering if _ct.order_is_numeric? + } rescue StandardError => e raise e unless ClosureTree.configuration.database_less end diff --git a/spec/pool_spec.rb b/spec/pool_spec.rb index de25c4fb..89d4e066 100644 --- a/spec/pool_spec.rb +++ b/spec/pool_spec.rb @@ -1,6 +1,11 @@ require 'spec_helper' describe 'Configuration' do + before(:each) do + # Make sure we start up with no active connection + ActiveRecord::Base.connection_pool.release_connection + end + it 'returns connection to the pool after has_closure_tree setup' do class TypeDuplicate < ActiveRecord::Base self.table_name = "namespace_type#{table_name_suffix}" From 1a37b406d4ad50d57daa28636fa4cf68916d2532 Mon Sep 17 00:00:00 2001 From: William Shupe Date: Wed, 26 Jun 2019 14:02:18 -0600 Subject: [PATCH 2/4] Fix hierarchy cleanup error when using type_caster This commit fixes an issue where a database proxy tries to access the type_caster on the aliased arel table. Since this is just an alias table of the current model, it makes sense to use the current model's type_caster for the alias. --- lib/closure_tree/hierarchy_maintenance.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/closure_tree/hierarchy_maintenance.rb b/lib/closure_tree/hierarchy_maintenance.rb index e3f4ee46..fce9e3e6 100644 --- a/lib/closure_tree/hierarchy_maintenance.rb +++ b/lib/closure_tree/hierarchy_maintenance.rb @@ -123,7 +123,7 @@ def cleanup! [:descendant_id, :ancestor_id].each do |foreign_key| alias_name = foreign_key.to_s.split('_').first + "s" - alias_table = Arel::Table.new(table_name).alias(alias_name) + alias_table = Arel::Table.new(table_name, type_caster: type_caster).alias(alias_name) arel_join = hierarchy_table.join(alias_table, Arel::Nodes::OuterJoin) .on(alias_table[primary_key].eq(hierarchy_table[foreign_key])) .join_sources From 76f12624b647afbb495e6bc2749148f4c4788d51 Mon Sep 17 00:00:00 2001 From: Nasia2404 Date: Thu, 23 Mar 2023 19:39:10 +0530 Subject: [PATCH 3/4] Added Codeowners File --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..6a801e3a --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @get-bridge/arcanine From 463c8e9a69d5eec997fb76f6e3888918b3cc8081 Mon Sep 17 00:00:00 2001 From: Robert Kiss Date: Mon, 26 Feb 2024 18:53:38 +0100 Subject: [PATCH 4/4] DoD-Introduce.PR.template.for.the.engineering.repositories (#3) --- .github/pull_request_template.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..01928f1d --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,29 @@ +#### JIRA + +#### Changes + +- + +#### Checklist +- [ ] Feature Flag Required +- [ ] Bug + +#### Test plan + +- [ ] Walk-through +- [ ] Peer review +- [ ] Inspection + - Detailed steps and prerequisites for validating the change: + - + +#### Risk Analysis - the risk of change is evaluated + +- [ ] Low - Majority of the changes are low risk which doesn’t require extra testing, only code review by 1 reviewer + - [ ] 1 reviewer +- [ ] Medium - Some portion of changes are medium risk which need peer testing and review by 2 reviewers + - [ ] 2 reviewers + - [ ] peer testing +- [ ] High - A very few breaking changes are high risk and need very throughout testing and review and also coordinated release process. + - [ ] 2 reviewers + - [ ] peer testing + - [ ] coordinated release