adaptive_alias 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0375ca9867e41c41fe18b38cb1f37ff2a0067367304f6481250cd573c5dc5be4
4
- data.tar.gz: bc0ebb4c4d63ea36e203b94f5c3ea0411c4fab408e93ea6c9dc0de5354c2db8c
3
+ metadata.gz: 53def64d14130ef1552a0a427246706ce42fb8696dfba356c323adcef3c39f97
4
+ data.tar.gz: 7c6b4ed35d6a0c90d06b09368b1f0c1617abfffac05f153015f3a4a8878ec6a5
5
5
  SHA512:
6
- metadata.gz: f0d5f519ab910bcf93c982f2ea6ca9c3e944ea0e90a07d6e938668b4575d450d6d019a60b62dd2020c373434e8ece4f7c1d9ea148ca269a4823718b80f8a8c07
7
- data.tar.gz: 9a699915af111f6e01aa6fac45a888583a629b1f6eb0d75c84a15188f329e3f34401a330a6ee33040453b4e9f2d6a018bca61626e0784944004832c3db6d6bc3
6
+ metadata.gz: 9c8b4ec7ad1588f922bf0af037061216699a056c023ea70975796c66dafd57cf254c5d4915a98cfa7e1b9836b53f61ca2961ea0b9aa399e2fe7dc55510192d23
7
+ data.tar.gz: c6a532d2f341729637a7ca9630fe1338ddeb5b553cc0ea897e6cb784d18adbd47db21254df82746a06e915c57a2f2567227436a9562eac21cb150174be16d5e7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## Change Log
2
2
 
3
+ ### [v0.2.1](https://github.com/khiav223577/adaptive_alias/compare/v0.2.0...v0.2.1) 2022/08/11
4
+ - [#13](https://github.com/khiav223577/adaptive_alias/pull/13) [Fix] Nested module include is not supported until ruby 3.0 (@khiav223577)
5
+ - [#12](https://github.com/khiav223577/adaptive_alias/pull/12) [Test] Add test cases to test column_names (@khiav223577)
6
+
3
7
  ### [v0.2.0](https://github.com/khiav223577/adaptive_alias/compare/v0.1.0...v0.2.0) 2022/08/05
4
8
  - [#11](https://github.com/khiav223577/adaptive_alias/pull/11) [Feature] Support polymorphic (@khiav223577)
5
9
  - [#10](https://github.com/khiav223577/adaptive_alias/pull/10) [Enhance] Prevent adding methods directly in class / module (@khiav223577)
@@ -46,6 +46,9 @@ module AdaptiveAlias
46
46
 
47
47
  expected_association_err_msgs = [
48
48
  "Mysql2::Error: Unknown column '#{klass.table_name}.#{current_column}' in 'where clause'".freeze,
49
+ ].freeze
50
+
51
+ expected_ambiguous_association_err_msgs = [
49
52
  "Mysql2::Error: Unknown column '#{current_column}' in 'field list'".freeze,
50
53
  ].freeze
51
54
 
@@ -67,7 +70,15 @@ module AdaptiveAlias
67
70
  @fix_association = proc do |relation, reflection, error|
68
71
  next false if not patch.removable
69
72
  next false if patch.removed
70
- next false if not expected_association_err_msgs.include?(error.message)
73
+
74
+ ambiguous = expected_ambiguous_association_err_msgs.include?(error.message)
75
+
76
+ if ambiguous
77
+ next false if relation and klass != relation.klass
78
+ next false if reflection and klass != reflection.klass
79
+ end
80
+
81
+ next false if not expected_association_err_msgs.include?(error.message) and not ambiguous
71
82
 
72
83
  patch.remove!
73
84
 
@@ -1,3 +1,3 @@
1
1
  module AdaptiveAlias
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
@@ -33,7 +33,7 @@ module AdaptiveAlias
33
33
  extend ActiveSupport::Concern
34
34
 
35
35
  included do
36
- patch = (column_names.include?(new_column) ? Patches::BackwardPatch : Patches::ForwardPatch).new(self, old_column, new_column)
36
+ patch = (column_names.include?(new_column.to_s) ? Patches::BackwardPatch : Patches::ForwardPatch).new(self, old_column, new_column)
37
37
  patch.apply!
38
38
  patch.mark_removable
39
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adaptive_alias
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - khiav reoy