adaptive_alias 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/adaptive_alias/patches/base.rb +12 -1
- data/lib/adaptive_alias/version.rb +1 -1
- data/lib/adaptive_alias.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 53def64d14130ef1552a0a427246706ce42fb8696dfba356c323adcef3c39f97
|
|
4
|
+
data.tar.gz: 7c6b4ed35d6a0c90d06b09368b1f0c1617abfffac05f153015f3a4a8878ec6a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
|
data/lib/adaptive_alias.rb
CHANGED
|
@@ -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
|