acts_as_list 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/acts_as_list/active_record/acts/list.rb +7 -4
- data/lib/acts_as_list/active_record/acts/position_column_method_definer.rb +14 -6
- data/lib/acts_as_list/active_record/acts/sequential_updates_method_definer.rb +15 -15
- data/lib/acts_as_list/active_record/acts/with_connection.rb +25 -0
- data/lib/acts_as_list/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af90a91e87476f41d5712ba02b1e409558b4b96e1a8ad4c448a18c21f6a39d88
|
4
|
+
data.tar.gz: 8441f44a8ad1e71639a29dc6e11477b728a0d8dbbe78d6d1e93d465ef7384697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15add9a3324c4a2aa8e03de8bae61be55e05362a65eac09fbd9f3d0924d8e79f7ebdbbb2bcff98cdec58830c041831385c2b5795c4f5857e1c220fc4aec49c1b
|
7
|
+
data.tar.gz: c57ac0454483abbe36e2c37dfb63525c40254f4f419a11367356a505df611d49cc55b422143a30bdbe624788e785d24f1effd6b9b4478d5c8293373e61292056
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## Unreleased
|
8
8
|
|
9
|
+
## v1.2.3 - 2024-10-14
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
- Use `.with_connection do |connection|` where possible instead of `.connection` [\#441](https://github.com/brendon/acts_as_list/pull/441) ([flood4life])
|
13
|
+
|
9
14
|
## v1.2.2 - 2024-07-16
|
10
15
|
|
11
16
|
### Fixed
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './with_connection'
|
4
|
+
|
3
5
|
module ActiveRecord
|
4
6
|
module Acts #:nodoc:
|
5
7
|
module List #:nodoc:
|
@@ -459,7 +461,9 @@ module ActiveRecord
|
|
459
461
|
|
460
462
|
# When using raw column name it must be quoted otherwise it can raise syntax errors with SQL keywords (e.g. order)
|
461
463
|
def quoted_position_column
|
462
|
-
@_quoted_position_column ||= self.class.connection
|
464
|
+
@_quoted_position_column ||= ActiveRecord::Acts::List::WithConnection.new(self.class).call do |connection|
|
465
|
+
connection.quote_column_name(position_column)
|
466
|
+
end
|
463
467
|
end
|
464
468
|
|
465
469
|
# Used in order clauses
|
@@ -481,9 +485,8 @@ module ActiveRecord
|
|
481
485
|
requirement.satisfied_by?(version)
|
482
486
|
end
|
483
487
|
|
484
|
-
def primary_key_condition(id =
|
485
|
-
|
486
|
-
id ? primary_keys.zip(Array.wrap(id)).to_h : slice(*primary_keys)
|
488
|
+
def primary_key_condition(id = self.id)
|
489
|
+
{ self.class.primary_key => [id] }
|
487
490
|
end
|
488
491
|
end
|
489
492
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './with_connection'
|
4
|
+
|
3
5
|
module ActiveRecord::Acts::List::PositionColumnMethodDefiner #:nodoc:
|
4
6
|
def self.call(caller_class, position_column, touch_on_update)
|
5
7
|
define_class_methods(caller_class, position_column, touch_on_update)
|
@@ -15,7 +17,9 @@ module ActiveRecord::Acts::List::PositionColumnMethodDefiner #:nodoc:
|
|
15
17
|
def self.define_class_methods(caller_class, position_column, touch_on_update)
|
16
18
|
caller_class.class_eval do
|
17
19
|
define_singleton_method :quoted_position_column do
|
18
|
-
@_quoted_position_column ||=
|
20
|
+
@_quoted_position_column ||= ActiveRecord::Acts::List::WithConnection.new(self).call do |connection|
|
21
|
+
connection.quote_column_name(position_column)
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
define_singleton_method :quoted_position_column_with_table_name do
|
@@ -72,18 +76,22 @@ module ActiveRecord::Acts::List::PositionColumnMethodDefiner #:nodoc:
|
|
72
76
|
cached_quoted_now = quoted_current_time_from_proper_timezone
|
73
77
|
|
74
78
|
timestamp_attributes_for_update_in_model.map do |attr|
|
75
|
-
|
79
|
+
ActiveRecord::Acts::List::WithConnection.new(self.class).call do |connection|
|
80
|
+
", #{connection.quote_column_name(attr)} = #{cached_quoted_now}"
|
81
|
+
end
|
76
82
|
end.join
|
77
83
|
end
|
78
84
|
|
79
85
|
private
|
80
86
|
|
81
87
|
def quoted_current_time_from_proper_timezone
|
82
|
-
self.class.connection
|
83
|
-
|
84
|
-
|
88
|
+
ActiveRecord::Acts::List::WithConnection.new(self.class).call do |connection|
|
89
|
+
connection.quote(
|
90
|
+
connection.quoted_date(
|
91
|
+
current_time_from_proper_timezone
|
92
|
+
)
|
85
93
|
)
|
86
|
-
|
94
|
+
end
|
87
95
|
end
|
88
96
|
end
|
89
97
|
end
|
@@ -1,24 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './with_connection'
|
4
|
+
|
3
5
|
module ActiveRecord::Acts::List::SequentialUpdatesMethodDefiner #:nodoc:
|
4
6
|
def self.call(caller_class, column, sequential_updates_option)
|
5
7
|
caller_class.class_eval do
|
6
8
|
define_method :sequential_updates? do
|
7
|
-
if
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
else
|
21
|
-
@sequential_updates
|
9
|
+
return @sequential_updates if defined?(@sequential_updates)
|
10
|
+
|
11
|
+
return @sequential_updates = sequential_updates_option unless sequential_updates_option.nil?
|
12
|
+
|
13
|
+
ActiveRecord::Acts::List::WithConnection.new(caller_class).call do |connection|
|
14
|
+
table_exists =
|
15
|
+
if active_record_version_is?('>= 5')
|
16
|
+
connection.data_source_exists?(caller_class.table_name)
|
17
|
+
else
|
18
|
+
connection.table_exists?(caller_class.table_name)
|
19
|
+
end
|
20
|
+
index_exists = connection.index_exists?(caller_class.table_name, column, unique: true)
|
21
|
+
@sequential_updates = table_exists && index_exists
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module Acts
|
5
|
+
module List
|
6
|
+
class WithConnection
|
7
|
+
def initialize(recipient)
|
8
|
+
@recipient = recipient
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :recipient
|
12
|
+
|
13
|
+
def call
|
14
|
+
if recipient.respond_to?(:with_connection)
|
15
|
+
recipient.with_connection do |connection|
|
16
|
+
yield connection
|
17
|
+
end
|
18
|
+
else
|
19
|
+
yield recipient.connection
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/acts_as_list/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swanand Pagnis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-10-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/acts_as_list/active_record/acts/scope_method_definer.rb
|
151
151
|
- lib/acts_as_list/active_record/acts/sequential_updates_method_definer.rb
|
152
152
|
- lib/acts_as_list/active_record/acts/top_of_list_method_definer.rb
|
153
|
+
- lib/acts_as_list/active_record/acts/with_connection.rb
|
153
154
|
- lib/acts_as_list/version.rb
|
154
155
|
homepage: https://github.com/brendon/acts_as_list
|
155
156
|
licenses:
|