atomically 1.1.1 → 1.1.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/.rubocop.yml +31 -32
- data/.travis.yml +17 -4
- data/CHANGELOG.md +9 -1
- data/README.md +4 -2
- data/atomically.gemspec +1 -1
- data/gemfiles/3.2.gemfile +3 -4
- data/gemfiles/4.2.gemfile +3 -4
- data/gemfiles/5.0.gemfile +3 -4
- data/gemfiles/5.1.gemfile +3 -4
- data/gemfiles/5.2.gemfile +3 -4
- data/gemfiles/6.0.gemfile +3 -4
- data/lib/atomically/query_service.rb +14 -4
- data/lib/atomically/version.rb +1 -1
- metadata +2 -3
- data/gemfiles/6.0.makara.gemfile +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c08c4d945a90102861c424a610fab072472cf17e31497936987ec842db6be426
|
4
|
+
data.tar.gz: c8c2b834fb5a652bdf3f31eb16fd0996ff2b3762613a31be57b038a7afcf9bd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d4ab1744413db5f7c14d3982b94289c836c7d007206fdc4f7cc40c2398ce165b97b65d95d12a095a915724e9fff3a59f2f35957f8fb6f72ccd7557ef12255fb
|
7
|
+
data.tar.gz: 8016f81e284201892faa8f8cad82302c8b674d50fc1181906b970d7e73533a886de33be9b22a61df8d180cf667292560ad28e595ece0893d45d63aeb798f55fb
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rails
|
4
|
+
|
1
5
|
AllCops:
|
2
6
|
DisabledByDefault: true
|
3
7
|
Exclude: []
|
@@ -73,10 +77,6 @@ Layout/EndAlignment:
|
|
73
77
|
Description: 'Align ends correctly.'
|
74
78
|
Enabled: true
|
75
79
|
|
76
|
-
Lint/EndInMethod:
|
77
|
-
Description: 'END blocks should not be placed inside method definitions.'
|
78
|
-
Enabled: true
|
79
|
-
|
80
80
|
Lint/EnsureReturn:
|
81
81
|
Description: 'Do not use return in an ensure block.'
|
82
82
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-return-ensure'
|
@@ -90,7 +90,7 @@ Lint/FormatParameterMismatch:
|
|
90
90
|
Description: 'The number of parameters to format/sprint must match the fields.'
|
91
91
|
Enabled: true
|
92
92
|
|
93
|
-
Lint/
|
93
|
+
Lint/SuppressedException:
|
94
94
|
Description: "Don't suppress exception."
|
95
95
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
|
96
96
|
Enabled: true
|
@@ -139,7 +139,7 @@ Lint/ShadowingOuterLocalVariable:
|
|
139
139
|
for block arguments or block local variables.
|
140
140
|
Enabled: true
|
141
141
|
|
142
|
-
Lint/
|
142
|
+
Lint/RedundantStringCoercion:
|
143
143
|
Description: 'Checks for Object#to_s usage in string interpolation.'
|
144
144
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-to-s'
|
145
145
|
Enabled: true
|
@@ -148,7 +148,7 @@ Lint/UnderscorePrefixedVariableName:
|
|
148
148
|
Description: 'Do not use prefix `_` for a variable that is used.'
|
149
149
|
Enabled: true
|
150
150
|
|
151
|
-
Lint/
|
151
|
+
Lint/RedundantCopDisableDirective:
|
152
152
|
Description: >-
|
153
153
|
Checks for rubocop:disable comments that can be removed.
|
154
154
|
Note: this cop is not disabled when disabling all cops.
|
@@ -221,7 +221,7 @@ Metrics/CyclomaticComplexity:
|
|
221
221
|
of test cases needed to validate a method.
|
222
222
|
Enabled: true
|
223
223
|
|
224
|
-
|
224
|
+
Layout/LineLength:
|
225
225
|
Description: 'Limit lines to 120 characters.'
|
226
226
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
|
227
227
|
Max: 120
|
@@ -285,7 +285,7 @@ Performance/ReverseEach:
|
|
285
285
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
|
286
286
|
Enabled: true
|
287
287
|
|
288
|
-
|
288
|
+
Style/Sample:
|
289
289
|
Description: >-
|
290
290
|
Use `sample` instead of `shuffle.first`,
|
291
291
|
`shuffle.last`, and `shuffle[Fixnum]`.
|
@@ -353,7 +353,7 @@ Rails/TimeZone:
|
|
353
353
|
Description: 'Checks the correct usage of time zone aware methods.'
|
354
354
|
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
|
355
355
|
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
|
356
|
-
Enabled:
|
356
|
+
Enabled: false
|
357
357
|
|
358
358
|
Rails/Validation:
|
359
359
|
Description: 'Use validates :attribute, hash of validations.'
|
@@ -375,21 +375,21 @@ Style/Alias:
|
|
375
375
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
|
376
376
|
Enabled: true
|
377
377
|
|
378
|
-
Layout/
|
378
|
+
Layout/ArrayAlignment:
|
379
379
|
Description: >-
|
380
380
|
Align the elements of an array literal if they span more than
|
381
381
|
one line.
|
382
382
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#align-multiline-arrays'
|
383
383
|
Enabled: true
|
384
384
|
|
385
|
-
Layout/
|
385
|
+
Layout/HashAlignment:
|
386
386
|
Description: >-
|
387
387
|
Align the elements of a hash literal if they span more than
|
388
388
|
one line.
|
389
389
|
EnforcedHashRocketStyle: table
|
390
390
|
Enabled: true
|
391
391
|
|
392
|
-
Layout/
|
392
|
+
Layout/ParameterAlignment:
|
393
393
|
Description: >-
|
394
394
|
Align the parameters of a method call if they span more
|
395
395
|
than one line.
|
@@ -448,10 +448,6 @@ Style/BlockDelimiters:
|
|
448
448
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
|
449
449
|
Enabled: true
|
450
450
|
|
451
|
-
Style/BracesAroundHashParameters:
|
452
|
-
Description: 'Enforce braces style around hash parameters.'
|
453
|
-
Enabled: true
|
454
|
-
|
455
451
|
Style/CaseEquality:
|
456
452
|
Description: 'Avoid explicit use of the case equality operator(===).'
|
457
453
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality'
|
@@ -596,7 +592,7 @@ Style/EndBlock:
|
|
596
592
|
Layout/EndOfLine:
|
597
593
|
Description: 'Use Unix-style line endings.'
|
598
594
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#crlf'
|
599
|
-
Enabled:
|
595
|
+
Enabled: false
|
600
596
|
|
601
597
|
Style/EvenOdd:
|
602
598
|
Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
|
@@ -617,14 +613,14 @@ Layout/InitialIndentation:
|
|
617
613
|
Checks the indentation of the first non-blank non-comment line in a file.
|
618
614
|
Enabled: true
|
619
615
|
|
620
|
-
Layout/
|
616
|
+
Layout/FirstArgumentIndentation:
|
621
617
|
Description: 'Checks the indentation of the first parameter in a method call.'
|
622
618
|
Enabled: true
|
623
619
|
|
624
|
-
|
620
|
+
Lint/FlipFlop:
|
625
621
|
Description: 'Checks for flip flops'
|
626
622
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops'
|
627
|
-
Enabled:
|
623
|
+
Enabled: false
|
628
624
|
|
629
625
|
Style/For:
|
630
626
|
Description: 'Checks use of for or each in multiline loops.'
|
@@ -634,9 +630,12 @@ Style/For:
|
|
634
630
|
Style/FormatString:
|
635
631
|
Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
|
636
632
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
|
637
|
-
EnforcedStyle:
|
633
|
+
EnforcedStyle: percent
|
638
634
|
Enabled: true
|
639
635
|
|
636
|
+
Style/FormatStringToken:
|
637
|
+
Enabled: false
|
638
|
+
|
640
639
|
Style/GlobalVars:
|
641
640
|
Description: 'Do not introduce global variables.'
|
642
641
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
|
@@ -676,14 +675,14 @@ Layout/IndentationWidth:
|
|
676
675
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation'
|
677
676
|
Enabled: true
|
678
677
|
|
679
|
-
Layout/
|
678
|
+
Layout/FirstArrayElementIndentation:
|
680
679
|
Description: >-
|
681
680
|
Checks the indentation of the first element in an array
|
682
681
|
literal.
|
683
682
|
EnforcedStyle: consistent
|
684
683
|
Enabled: true
|
685
684
|
|
686
|
-
Layout/
|
685
|
+
Layout/FirstHashElementIndentation:
|
687
686
|
Description: 'Checks the indentation of the first key in a hash literal.'
|
688
687
|
EnforcedStyle: consistent
|
689
688
|
Enabled: true
|
@@ -862,7 +861,7 @@ Style/PercentQLiterals:
|
|
862
861
|
Style/PerlBackrefs:
|
863
862
|
Description: 'Avoid Perl-style regex back references.'
|
864
863
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
|
865
|
-
Enabled:
|
864
|
+
Enabled: false
|
866
865
|
|
867
866
|
Naming/PredicateName:
|
868
867
|
Description: 'Check the names of predicate methods.'
|
@@ -940,11 +939,11 @@ Style/SingleLineBlockParams:
|
|
940
939
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
|
941
940
|
Methods:
|
942
941
|
- reduce:
|
943
|
-
-
|
944
|
-
-
|
942
|
+
- sum
|
943
|
+
- v
|
945
944
|
- inject:
|
946
|
-
-
|
947
|
-
-
|
945
|
+
- sum
|
946
|
+
- v
|
948
947
|
Enabled: true
|
949
948
|
|
950
949
|
Style/SingleLineMethods:
|
@@ -1123,7 +1122,7 @@ Layout/Tab:
|
|
1123
1122
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation'
|
1124
1123
|
Enabled: true
|
1125
1124
|
|
1126
|
-
Layout/
|
1125
|
+
Layout/TrailingEmptyLines:
|
1127
1126
|
Description: 'Checks trailing blank lines and final newline.'
|
1128
1127
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#newline-eof'
|
1129
1128
|
Enabled: true
|
@@ -1178,11 +1177,11 @@ Style/UnlessElse:
|
|
1178
1177
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-else-with-unless'
|
1179
1178
|
Enabled: true
|
1180
1179
|
|
1181
|
-
Style/
|
1180
|
+
Style/RedundantCapitalW:
|
1182
1181
|
Description: 'Checks for %W when interpolation is not needed.'
|
1183
1182
|
Enabled: true
|
1184
1183
|
|
1185
|
-
Style/
|
1184
|
+
Style/RedundantPercentQ:
|
1186
1185
|
Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
|
1187
1186
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-q'
|
1188
1187
|
Enabled: true
|
data/.travis.yml
CHANGED
@@ -3,6 +3,7 @@ language: ruby
|
|
3
3
|
rvm:
|
4
4
|
- 2.2
|
5
5
|
- 2.6
|
6
|
+
- 2.7
|
6
7
|
services:
|
7
8
|
- mysql
|
8
9
|
addons:
|
@@ -23,19 +24,31 @@ gemfile:
|
|
23
24
|
matrix:
|
24
25
|
include:
|
25
26
|
- env: DB=makara_mysql
|
26
|
-
gemfile: gemfiles/6.0.
|
27
|
+
gemfile: gemfiles/6.0.gemfile
|
27
28
|
rvm: 2.6
|
28
29
|
- env: DB=makara_pg
|
29
|
-
gemfile: gemfiles/6.0.
|
30
|
+
gemfile: gemfiles/6.0.gemfile
|
30
31
|
rvm: 2.6
|
32
|
+
- env: DB=makara_mysql
|
33
|
+
gemfile: gemfiles/6.0.gemfile
|
34
|
+
rvm: 2.7
|
35
|
+
- env: DB=makara_pg
|
36
|
+
gemfile: gemfiles/6.0.gemfile
|
37
|
+
rvm: 2.7
|
31
38
|
exclude:
|
32
39
|
- gemfile: gemfiles/3.2.gemfile
|
33
40
|
rvm: 2.6
|
41
|
+
- gemfile: gemfiles/3.2.gemfile
|
42
|
+
rvm: 2.7
|
43
|
+
- gemfile: gemfiles/4.2.gemfile
|
44
|
+
rvm: 2.7
|
34
45
|
- gemfile: gemfiles/6.0.gemfile
|
35
46
|
rvm: 2.2
|
36
47
|
before_install:
|
37
|
-
-
|
38
|
-
|
48
|
+
- if `ruby -e 'exit(RUBY_VERSION.to_f < 2.7)'`; then
|
49
|
+
gem i rubygems-update -v '< 3' && update_rubygems;
|
50
|
+
gem install bundler -v '< 2';
|
51
|
+
fi
|
39
52
|
- gem --version
|
40
53
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
41
54
|
- chmod +x ./cc-test-reporter
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
## Change Log
|
2
2
|
|
3
|
+
### [v1.1.2](https://github.com/khiav223577/atomically/compare/v1.1.1...v1.1.2) 2020/09/01
|
4
|
+
- [#19](https://github.com/khiav223577/atomically/pull/19) Fix: changed attributes are not updated when calling `atomically.update` (@khiav223577)
|
5
|
+
- [#18](https://github.com/khiav223577/atomically/pull/18) Support Ruby 2.7 (@khiav223577)
|
6
|
+
- [#17](https://github.com/khiav223577/atomically/pull/17) specify gem versions by ENV['DB'] (@khiav223577)
|
7
|
+
|
8
|
+
### [v1.1.1](https://github.com/khiav223577/atomically/compare/v1.1.0...v1.1.1) 2019/11/01
|
9
|
+
- [#16](https://github.com/khiav223577/atomically/pull/16) Fix: `create_or_plus` is broken when using `makara` adapter (@khiav223577)
|
10
|
+
|
3
11
|
### [v1.1.0](https://github.com/khiav223577/atomically/compare/v1.0.6...v1.1.0) 2019/10/23
|
4
|
-
- [#12](https://github.com/khiav223577/atomically/pull/12) Support
|
12
|
+
- [#12](https://github.com/khiav223577/atomically/pull/12) Support PostgreSQL (@khiav223577)
|
5
13
|
- [#14](https://github.com/khiav223577/atomically/pull/14) Support Rails 6.0 (@khiav223577)
|
6
14
|
- [#13](https://github.com/khiav223577/atomically/pull/13) Remove deprecated codeclimate-test-reporter gem (@khiav223577)
|
7
15
|
- [#11](https://github.com/khiav223577/atomically/pull/11) Fix: Non-attribute arguments will be disallowed in Rails 6.0 (@khiav223577)
|
data/README.md
CHANGED
@@ -10,8 +10,10 @@
|
|
10
10
|
|
11
11
|
All methods are defined in `Atomically::QueryService` instead of defining in `ActiveRecord` directly, in order not to pollute the model instance.
|
12
12
|
|
13
|
-
|
14
|
-
-
|
13
|
+
## Supports
|
14
|
+
- Ruby 2.2 ~ 2.7
|
15
|
+
- Rails 3.2, 4.2, 5.0, 5.1, 5.2, 6.0
|
16
|
+
- MySQL, PostgreSQL
|
15
17
|
|
16
18
|
## Table of contents
|
17
19
|
|
data/atomically.gemspec
CHANGED
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_development_dependency 'sqlite3', '~> 1.3'
|
40
40
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
41
41
|
spec.add_development_dependency 'mysql2', '>= 0.3'
|
42
|
-
spec.add_development_dependency
|
42
|
+
spec.add_development_dependency 'pg', '~> 0.18'
|
43
43
|
spec.add_development_dependency 'pluck_all', '>= 2.0.3'
|
44
44
|
spec.add_development_dependency 'timecop', '~> 0.9.1'
|
45
45
|
|
data/gemfiles/3.2.gemfile
CHANGED
@@ -3,10 +3,9 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'activerecord', '~> 3.2.0'
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
gem 'mysql2', '0.3.21' if %w[mysql makara_mysql].include?(ENV['DB'])
|
7
|
+
gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
|
8
|
+
gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
|
10
9
|
gem 'simplecov'
|
11
10
|
gem 'i18n', '< 1.6'
|
12
11
|
gem 'pluck_all', '>= 2.0.3'
|
data/gemfiles/4.2.gemfile
CHANGED
@@ -3,10 +3,9 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'activerecord', '~> 4.2.0'
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
gem 'mysql2', '0.3.21' if %w[mysql makara_mysql].include?(ENV['DB'])
|
7
|
+
gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
|
8
|
+
gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
|
10
9
|
gem 'simplecov'
|
11
10
|
gem 'i18n', '< 1.6'
|
12
11
|
gem 'pluck_all', '>= 2.0.3'
|
data/gemfiles/5.0.gemfile
CHANGED
@@ -3,10 +3,9 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'activerecord', '~> 5.0.0'
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
gem 'mysql2', '0.3.21' if %w[mysql makara_mysql].include?(ENV['DB'])
|
7
|
+
gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
|
8
|
+
gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
|
10
9
|
gem 'simplecov'
|
11
10
|
gem 'i18n', '< 1.6'
|
12
11
|
gem 'pluck_all', '>= 2.0.3'
|
data/gemfiles/5.1.gemfile
CHANGED
@@ -3,10 +3,9 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'activerecord', '~> 5.1.0'
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
gem 'mysql2', '0.3.21' if %w[mysql makara_mysql].include?(ENV['DB'])
|
7
|
+
gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
|
8
|
+
gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
|
10
9
|
gem 'simplecov'
|
11
10
|
gem 'i18n', '< 1.6'
|
12
11
|
gem 'pluck_all', '>= 2.0.3'
|
data/gemfiles/5.2.gemfile
CHANGED
@@ -3,10 +3,9 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'activerecord', '~> 5.2.0'
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
gem 'mysql2', '0.5.1' if %w[mysql makara_mysql].include?(ENV['DB'])
|
7
|
+
gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
|
8
|
+
gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
|
10
9
|
gem 'simplecov'
|
11
10
|
gem 'i18n', '< 1.6'
|
12
11
|
gem 'pluck_all', '>= 2.0.3'
|
data/gemfiles/6.0.gemfile
CHANGED
@@ -3,10 +3,9 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'activerecord', '~> 6.0.0'
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
gem 'mysql2', '0.5.1' if %w[mysql makara_mysql].include?(ENV['DB'])
|
7
|
+
gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
|
8
|
+
gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
|
10
9
|
gem 'simplecov'
|
11
10
|
gem 'pluck_all', '>= 2.0.4'
|
12
11
|
gem 'timecop', '~> 0.9.1'
|
@@ -53,7 +53,12 @@ class Atomically::QueryService
|
|
53
53
|
|
54
54
|
def update(attrs, from: :not_set)
|
55
55
|
success = update_and_return_number_of_updated_rows(attrs, from) == 1
|
56
|
-
|
56
|
+
|
57
|
+
if success
|
58
|
+
assign_without_changes(attrs)
|
59
|
+
@model.send(:clear_attribute_changes, @model.changes.keys)
|
60
|
+
end
|
61
|
+
|
57
62
|
return success
|
58
63
|
end
|
59
64
|
|
@@ -98,7 +103,7 @@ class Atomically::QueryService
|
|
98
103
|
return service.mysql_quote_columns_for_plus.join(', ') if adapter_check_service.mysql?
|
99
104
|
return {
|
100
105
|
conflict_target: conflict_target,
|
101
|
-
columns: service.pg_quote_columns_for_plus.join(', ')
|
106
|
+
columns: service.pg_quote_columns_for_plus.join(', '),
|
102
107
|
}
|
103
108
|
end
|
104
109
|
|
@@ -118,12 +123,17 @@ class Atomically::QueryService
|
|
118
123
|
query.where("(#{@klass.from(query.where('')).select('COUNT(*)').to_sql}) = ?", expected_size)
|
119
124
|
end
|
120
125
|
|
121
|
-
def update_and_return_number_of_updated_rows(attrs,
|
126
|
+
def update_and_return_number_of_updated_rows(attrs, from_value)
|
122
127
|
model = @model
|
123
128
|
return open_update_all_scope do
|
124
129
|
update(updated_at: Time.now)
|
130
|
+
|
131
|
+
model.changes.each do |column, (_old_value, new_value)|
|
132
|
+
update(column => new_value)
|
133
|
+
end
|
134
|
+
|
125
135
|
attrs.each do |column, value|
|
126
|
-
old_value = (
|
136
|
+
old_value = (from_value == :not_set ? model[column] : from_value)
|
127
137
|
where(column => old_value).update(column => value) if old_value != value
|
128
138
|
end
|
129
139
|
end
|
data/lib/atomically/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atomically
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khiav reoy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -210,7 +210,6 @@ files:
|
|
210
210
|
- gemfiles/5.1.gemfile
|
211
211
|
- gemfiles/5.2.gemfile
|
212
212
|
- gemfiles/6.0.gemfile
|
213
|
-
- gemfiles/6.0.makara.gemfile
|
214
213
|
- lib/atomically.rb
|
215
214
|
- lib/atomically/active_record/extension.rb
|
216
215
|
- lib/atomically/adapter_check_service.rb
|
data/gemfiles/6.0.makara.gemfile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'activerecord', '~> 6.0.0'
|
4
|
-
|
5
|
-
group :test do
|
6
|
-
case ENV['DB']
|
7
|
-
when 'mysql' ; gem 'mysql2', '0.5.1'
|
8
|
-
when 'postgres' ; gem 'pg', '~> 0.18'
|
9
|
-
end
|
10
|
-
gem 'simplecov'
|
11
|
-
gem 'pluck_all', '>= 2.0.4'
|
12
|
-
gem 'timecop', '~> 0.9.1'
|
13
|
-
gem 'update_all_scope', '~> 0.1.0'
|
14
|
-
gem 'makara', '~> 0.4.1'
|
15
|
-
end
|
16
|
-
|
17
|
-
gemspec path: '../'
|