mobility 1.3.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 488c8b1ec0f603d226b7a0dd54064a27ede153b1c8c3bd1ae078bcfec0dd74e2
4
- data.tar.gz: ebce70b5815c7618b908459c59bc514647b55f2e792641bc3d400547fb5ae533
3
+ metadata.gz: a0c4bf66ecc6f29971de5824593cec2e01ebc83b00b31211c34c6400533258b2
4
+ data.tar.gz: 76a583703568606c2e7da0b4584eff3ba0bac945c470c082670bea5cc089f0a5
5
5
  SHA512:
6
- metadata.gz: 8d8dc37e4dd38ead1eb16b593ca153876179770a23b32a63b2c6850509326590c8c80596351328b48c6e40e25df48b99f106e6cbcddd0b940381eaf0c7e41fd6
7
- data.tar.gz: b0afa4c0962c240658c0e5fe109c76e6db533b7f1ad1679b4ed38094c8dd48cb581fb15f8ac50d57078238d98cade3198b562ee64d2ed1ca9c9af3f3bda5e72c
6
+ metadata.gz: 1fb87d197dd5828cbeba90c7c3ca987dca7527571a4311145486c9eff76fe7c9bfc222098053c6c024dcf184bbe068f577ec621e8cd183883d3ba4830b684c87
7
+ data.tar.gz: d8bf29cf123fee01d6de948c62ea95dd58a8a2cbaee30fa5aa6b666a82763401201ddc03d364a802a781cca88fe1650e2eb812595c08a3e8e474213336598c68
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ## 1.3
4
4
 
5
+ ### 1.3.2
6
+
7
+ - Handle `nil` assignment for PgHash
8
+ ([#665](https://github.com/shioyama/mobility/pull/665)), thanks
9
+ [unavailabl3](https://github.com/unavailabl3)!
10
+
11
+ ### 1.3.1
12
+
13
+ - Use classify to generate table name
14
+ ([#634](https://github.com/shioyama/mobility/pull/634)), thanks
15
+ [divanburger](https://github.com/divanburger)!
16
+ - Fix select + count in ActiveRecord
17
+ 8 ([#659](https://github.com/shioyama/mobility/pull/659))
18
+
5
19
  ### 1.3.0
6
20
 
7
21
  - Only support ActiveRecord >= 7.0
data/Gemfile.lock CHANGED
@@ -1,32 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mobility (1.3.0.rc3)
4
+ mobility (1.3.1)
5
5
  i18n (>= 0.6.10, < 2)
6
6
  request_store (~> 1.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (7.1.5)
12
- activesupport (= 7.1.5)
13
- activerecord (7.1.5)
14
- activemodel (= 7.1.5)
15
- activesupport (= 7.1.5)
11
+ activemodel (8.0.0)
12
+ activesupport (= 8.0.0)
13
+ activerecord (8.0.0)
14
+ activemodel (= 8.0.0)
15
+ activesupport (= 8.0.0)
16
16
  timeout (>= 0.4.0)
17
- activesupport (7.1.5)
17
+ activesupport (8.0.0)
18
18
  base64
19
19
  benchmark (>= 0.3)
20
20
  bigdecimal
21
- concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ concurrent-ruby (~> 1.0, >= 1.3.1)
22
22
  connection_pool (>= 2.2.5)
23
23
  drb
24
24
  i18n (>= 1.6, < 2)
25
25
  logger (>= 1.4.2)
26
26
  minitest (>= 5.1)
27
- mutex_m
28
27
  securerandom (>= 0.3)
29
- tzinfo (~> 2.0)
28
+ tzinfo (~> 2.0, >= 2.0.5)
29
+ uri (>= 0.13.1)
30
30
  base64 (0.2.0)
31
31
  benchmark (0.4.0)
32
32
  benchmark-ips (2.14.0)
@@ -62,9 +62,7 @@ GEM
62
62
  logger (1.6.1)
63
63
  lumberjack (1.2.10)
64
64
  method_source (1.1.0)
65
- mini_portile2 (2.8.8)
66
65
  minitest (5.25.2)
67
- mutex_m (0.3.0)
68
66
  nenv (0.3.0)
69
67
  notiffany (0.1.3)
70
68
  nenv (~> 0.1)
@@ -75,7 +73,7 @@ GEM
75
73
  pry-byebug (3.10.1)
76
74
  byebug (~> 11.0)
77
75
  pry (>= 0.13, < 0.15)
78
- rack (3.1.8)
76
+ rack (2.2.7)
79
77
  rake (12.3.3)
80
78
  rb-fsevent (0.11.2)
81
79
  rb-inotify (0.11.1)
@@ -97,19 +95,19 @@ GEM
97
95
  rspec-support (3.13.1)
98
96
  securerandom (0.3.2)
99
97
  shellany (0.0.1)
100
- sqlite3 (1.5.4)
101
- mini_portile2 (~> 2.8.0)
98
+ sqlite3 (2.3.1-x86_64-linux-gnu)
102
99
  thor (1.3.2)
103
100
  timeout (0.4.2)
104
101
  tzinfo (2.0.6)
105
102
  concurrent-ruby (~> 1.0)
103
+ uri (1.0.2)
106
104
  yard (0.9.37)
107
105
 
108
106
  PLATFORMS
109
107
  x86_64-linux
110
108
 
111
109
  DEPENDENCIES
112
- activerecord (~> 7.1.0)
110
+ activerecord (~> 8.0.0)
113
111
  benchmark-ips
114
112
  database_cleaner (~> 1.5, >= 1.5.3)
115
113
  guard-rspec
@@ -117,7 +115,7 @@ DEPENDENCIES
117
115
  pry-byebug
118
116
  rake (~> 12, >= 12.2.1)
119
117
  rspec (~> 3.0)
120
- sqlite3 (~> 1.5.0)
118
+ sqlite3 (>= 2.1.0)
121
119
  yard (~> 0.9.0)
122
120
 
123
121
  BUNDLED WITH
data/README.md CHANGED
@@ -54,7 +54,7 @@ Installation
54
54
  Add this line to your application's Gemfile:
55
55
 
56
56
  ```ruby
57
- gem 'mobility', '~> 1.3.0.rc3'
57
+ gem 'mobility', '~> 1.3.2'
58
58
  ```
59
59
 
60
60
  ### ActiveRecord (Rails)
@@ -22,6 +22,7 @@ Internal class used by ActiveRecord backends backed by a Postgres data type
22
22
  def write(locale, value, _options = nil)
23
23
  if value.nil?
24
24
  translations.delete(locale.to_s)
25
+ nil
25
26
  else
26
27
  translations[locale.to_s] = value
27
28
  end
@@ -102,7 +102,7 @@ columns to that table.
102
102
  def configure(options)
103
103
  table_name = model_class.table_name
104
104
  options[:table_name] ||= "#{table_name.singularize}_translations"
105
- options[:foreign_key] ||= table_name.downcase.singularize.camelize.foreign_key
105
+ options[:foreign_key] ||= table_name.classify.foreign_key
106
106
  if (association_name = options[:association_name]).present?
107
107
  options[:subclass_name] ||= association_name.to_s.singularize.camelize.freeze
108
108
  else
@@ -21,6 +21,9 @@ enabled for any one attribute on the model.
21
21
 
22
22
  requires :query, include: false
23
23
 
24
+ ATTRIBUTE_ALIAS_PREFIX = "__mobility_"
25
+ ATTRIBUTE_ALIAS = "#{ATTRIBUTE_ALIAS_PREFIX}%s_%s__"
26
+
24
27
  included_hook do |klass, backend_class|
25
28
  plugin = self
26
29
  if options[:query]
@@ -39,7 +42,7 @@ enabled for any one attribute on the model.
39
42
 
40
43
  class << self
41
44
  def attribute_alias(attribute, locale = Mobility.locale)
42
- "__mobility_%s_%s__" % [attribute, ::Mobility.normalize_locale(locale)]
45
+ ATTRIBUTE_ALIAS % [attribute, ::Mobility.normalize_locale(locale)]
43
46
  end
44
47
 
45
48
  def build_query(klass, locale = Mobility.locale, &block)
@@ -171,7 +174,7 @@ enabled for any one attribute on the model.
171
174
  base = keys.each_with_index.inject(self) do |query, (key, index)|
172
175
  next query unless klass.mobility_attribute?(key)
173
176
  keys[index] = backend_node(key)
174
- if method_name == "select" && query.order_values.any?
177
+ if method_name == "select"
175
178
  keys[index] = keys[index]
176
179
  .as(::Mobility::Plugins::ActiveRecord::Query.attribute_alias(key.to_s))
177
180
  end
@@ -182,6 +185,27 @@ enabled for any one attribute on the model.
182
185
  end
183
186
  end
184
187
 
188
+ if ::ActiveRecord::VERSION::MAJOR >= 8
189
+ # Fix for https://github.com/shioyama/mobility/pull/654#issuecomment-2503479112
190
+ # TODO: Make this better
191
+ def select_for_count
192
+ return super unless klass.respond_to?(:mobility_attribute?)
193
+
194
+ if select_values.any? { |value| value.right.start_with?(ATTRIBUTE_ALIAS_PREFIX) }
195
+ filtered_select_values = select_values.map do |value|
196
+ value.right.start_with?(ATTRIBUTE_ALIAS_PREFIX) ? value.left : value
197
+ end
198
+
199
+ # Copied from lib/active_record/relation/calculations.rb
200
+ with_connection do |conn|
201
+ arel_columns(filtered_select_values).map { |column| conn.visitor.compile(column) }.join(", ")
202
+ end
203
+ else
204
+ super
205
+ end
206
+ end
207
+ end
208
+
185
209
  # Return backend node for attribute name.
186
210
  # @param [Symbol,String] name Name of attribute
187
211
  # @param [Symbol] locale Locale
@@ -25,6 +25,14 @@ attributes only.
25
25
  attributes.merge(name.to_s => send(name))
26
26
  end)
27
27
  end
28
+
29
+ private
30
+
31
+ define_method :attribute_names_for_serialization do
32
+ return unless defined?(super)
33
+
34
+ super() + names.map(&:to_s)
35
+ end
28
36
  end
29
37
 
30
38
  # Applies attribute_methods plugin for a given option value.
@@ -8,7 +8,7 @@ module Mobility
8
8
  module VERSION
9
9
  MAJOR = 1
10
10
  MINOR = 3
11
- TINY = 0
11
+ TINY = 2
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobility
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
@@ -35,7 +35,7 @@ cert_chain:
35
35
  3I5AfnFAG4/1IwhadqwF5cl3jOUa7n3mS2OJl3tRCGuPvwAA9MV10hmwbQTXMrNK
36
36
  tD9kfT9eseUE4mfPnIaHOs4FiIoHniA7zdtjB7GIQ4cEpB6o
37
37
  -----END CERTIFICATE-----
38
- date: 2024-11-30 00:00:00.000000000 Z
38
+ date: 2025-01-25 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: request_store
metadata.gz.sig CHANGED
Binary file