adaptive_alias 0.2.2 → 0.2.3

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: 53def64d14130ef1552a0a427246706ce42fb8696dfba356c323adcef3c39f97
4
- data.tar.gz: 7c6b4ed35d6a0c90d06b09368b1f0c1617abfffac05f153015f3a4a8878ec6a5
3
+ metadata.gz: b0944e33c0d1dc0b83a734d921c7dadc3f37eaccd2356deebd9775168a98470c
4
+ data.tar.gz: 3132d4d8a7de8e5325a8505a79f377daf227322f045e2bdc08ec41443d182348
5
5
  SHA512:
6
- metadata.gz: 9c8b4ec7ad1588f922bf0af037061216699a056c023ea70975796c66dafd57cf254c5d4915a98cfa7e1b9836b53f61ca2961ea0b9aa399e2fe7dc55510192d23
7
- data.tar.gz: c6a532d2f341729637a7ca9630fe1338ddeb5b553cc0ea897e6cb784d18adbd47db21254df82746a06e915c57a2f2567227436a9562eac21cb150174be16d5e7
6
+ metadata.gz: 4cf0abcab7059c77833a1eb3e04672bb26fa8f5d86c5d710d2fb603a0ef12fd07cad2e8acc04eb9e8ae2b8b1b39d09dd1c50382143cd4fcb55d6d5ff648ec6be
7
+ data.tar.gz: ba28c61c515149710cffa4a97b23e4870e4b01f2da7e9114034e728e44cefe02a421c839ca1e8667c054660c274f78b0839bf9fd3eee5062b3ea03ff39554b33
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## Change Log
2
2
 
3
+ ### [upcoming](https://github.com/khiav223577/adaptive_alias/compare/v0.2.2...HEAD) 2022/08/15
4
+ - [#16](https://github.com/khiav223577/adaptive_alias/pull/16) [Enhance] No need to clone node (@khiav223577)
5
+ - [#15](https://github.com/khiav223577/adaptive_alias/pull/15) [Test] Add test cases to test calling pluck on same model (@khiav223577)
6
+
7
+ ### [v0.2.2](https://github.com/khiav223577/adaptive_alias/compare/v0.2.1...v0.2.2) 2022/08/11
8
+ - [#14](https://github.com/khiav223577/adaptive_alias/pull/14) [Fix] Fail to use backward-patch when target column has already been migrated (@khiav223577)
9
+
3
10
  ### [v0.2.1](https://github.com/khiav223577/adaptive_alias/compare/v0.2.0...v0.2.1) 2022/08/11
4
11
  - [#13](https://github.com/khiav223577/adaptive_alias/pull/13) [Fix] Nested module include is not supported until ruby 3.0 (@khiav223577)
5
12
  - [#12](https://github.com/khiav223577/adaptive_alias/pull/12) [Test] Add test cases to test column_names (@khiav223577)
@@ -4,7 +4,7 @@ module AdaptiveAlias
4
4
  module ActiveModelPatches
5
5
  module ApplyScope
6
6
  def apply_scope(scope, table, key, value)
7
- klass = table.instance_variable_get(:@klass) || table.send(:type_caster).send(:types)
7
+ klass = table.instance_variable_get(:@klass) || table.klass
8
8
  key = klass.attribute_aliases[key] || key
9
9
  super(scope, table, key, value)
10
10
  end
@@ -0,0 +1,26 @@
1
+ require 'active_record'
2
+
3
+ module AdaptiveAlias
4
+ module ActiveModelPatches
5
+ module ArelTable
6
+ def [](name)
7
+ name = name.to_s if name.is_a?(Symbol)
8
+ klass = self.klass
9
+ name = klass.attribute_aliases[name] || name if klass
10
+ super
11
+ end
12
+
13
+ def klass
14
+ return @type_caster.instance_variable_get(:@klass) if @type_caster.is_a?(ActiveRecord::TypeCaster::Connection)
15
+ return @type_caster.send(:types) if @type_caster.is_a?(ActiveRecord::TypeCaster::Map)
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ # https://github.com/rails/rails/commit/1ac40f16c5bc5246a4aaeab0558eb1c3078b3c6e
22
+ if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('6.1')
23
+ class Arel::Table
24
+ prepend AdaptiveAlias::ActiveModelPatches::ArelTable
25
+ end
26
+ end
@@ -46,6 +46,7 @@ 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
+ "Mysql2::Error: Unknown column '#{klass.table_name}.#{current_column}' in 'on clause'".freeze,
49
50
  ].freeze
50
51
 
51
52
  expected_ambiguous_association_err_msgs = [
@@ -87,7 +88,6 @@ module AdaptiveAlias
87
88
  next if node.left.name != current_column.to_s
88
89
  next if klass.table_name != node.left.relation.name
89
90
 
90
- node.left = node.left.clone
91
91
  node.left.name = alias_column.to_s
92
92
  end
93
93
  end
@@ -1,3 +1,3 @@
1
1
  module AdaptiveAlias
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
@@ -5,6 +5,7 @@ require 'adaptive_alias/active_model_patches/read_attribute'
5
5
  require 'adaptive_alias/active_model_patches/write_attribute'
6
6
  require 'adaptive_alias/active_model_patches/remove_alias_attribute'
7
7
  require 'adaptive_alias/active_model_patches/apply_scope'
8
+ require 'adaptive_alias/active_model_patches/arel_table'
8
9
  require 'adaptive_alias/patches/backward_patch'
9
10
  require 'adaptive_alias/patches/forward_patch'
10
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adaptive_alias
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - khiav reoy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-11 00:00:00.000000000 Z
11
+ date: 2022-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -124,6 +124,7 @@ files:
124
124
  - gemfiles/7.0.gemfile
125
125
  - lib/adaptive_alias.rb
126
126
  - lib/adaptive_alias/active_model_patches/apply_scope.rb
127
+ - lib/adaptive_alias/active_model_patches/arel_table.rb
127
128
  - lib/adaptive_alias/active_model_patches/read_attribute.rb
128
129
  - lib/adaptive_alias/active_model_patches/remove_alias_attribute.rb
129
130
  - lib/adaptive_alias/active_model_patches/write_attribute.rb