mobility 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of mobility might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 488c8b1ec0f603d226b7a0dd54064a27ede153b1c8c3bd1ae078bcfec0dd74e2
4
- data.tar.gz: ebce70b5815c7618b908459c59bc514647b55f2e792641bc3d400547fb5ae533
3
+ metadata.gz: e29c8ed1c4b5ff644843c06c90fa46ce9fa9dd951a64dfb40b2ff33961483edd
4
+ data.tar.gz: '0708f6107d1ac5a80fd99c7d7d098e6915c10ad457cf962fdcc8510bced56f58'
5
5
  SHA512:
6
- metadata.gz: 8d8dc37e4dd38ead1eb16b593ca153876179770a23b32a63b2c6850509326590c8c80596351328b48c6e40e25df48b99f106e6cbcddd0b940381eaf0c7e41fd6
7
- data.tar.gz: b0afa4c0962c240658c0e5fe109c76e6db533b7f1ad1679b4ed38094c8dd48cb581fb15f8ac50d57078238d98cade3198b562ee64d2ed1ca9c9af3f3bda5e72c
6
+ metadata.gz: 87975b6d967a5944c5cc5f1b0bc154eeff73437fd3a0bde826195236e070533cfc2ffbaa1188a3791d8bfb439179005210712a9a91894a9212881113b74a1910
7
+ data.tar.gz: d77ff76539f6f847ded56cada8746cd64a2398ddd2fe1fd33758f129ba737e996e083797e7dabe0769f9e41ab06f73b50b2f56635f8e9d5ab2e23f9c787408fa
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## 1.3
4
4
 
5
+ ### 1.3.1
6
+
7
+ - Use classify to generate table name
8
+ ([#634](https://github.com/shioyama/mobility/pull/634)), thanks
9
+ [divanburger](https://github.com/divanburger)!
10
+ - Fix select + count in ActiveRecord
11
+ 8 ([#659](https://github.com/shioyama/mobility/pull/659))
12
+
5
13
  ### 1.3.0
6
14
 
7
15
  - 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.0)
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.1'
58
58
  ```
59
59
 
60
60
  ### ActiveRecord (Rails)
@@ -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
@@ -8,7 +8,7 @@ module Mobility
8
8
  module VERSION
9
9
  MAJOR = 1
10
10
  MINOR = 3
11
- TINY = 0
11
+ TINY = 1
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.1
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: 2024-12-01 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