active_record_upsert 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +7 -0
- data/README.md +33 -0
- data/active_record_upsert.gemspec +3 -2
- data/lib/active_record_upsert/active_record/persistence.rb +2 -1
- data/lib/active_record_upsert/active_record.rb +4 -0
- data/lib/active_record_upsert/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17859791d0f8087ee15a23e7ba92b545228e5936
|
4
|
+
data.tar.gz: 5ca52ebcbd5c9464425b59bf0e5d6c474e6c9374
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 688ffdfffb32ff77e568e5bbdc37a4309ba154882a60c25ddea23c6fa67d22bee0b8907b186608d0a6bf3998728bf815a3baf0ce5c78bc8f504606b428a0baef
|
7
|
+
data.tar.gz: fdaa6610407f72f51950672a93026162095483daba7ca78cc46ee494ea9b834cfe348a6f2e1531f3ea2911ee0e376e43d63fa3e45d60098d040a30b0236297fe
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -2,3 +2,10 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in active_record_upsert.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
gem 'activerecord-jdbc-adapter', github: 'jensnockert/activerecord-jdbc-adapter', branch: 'activerecord-50'
|
7
|
+
|
8
|
+
gem 'activerecord-jdbcpostgresql-adapter',
|
9
|
+
github: 'jensnockert/activerecord-jdbc-adapter',
|
10
|
+
branch: 'activerecord-50',
|
11
|
+
platform: :jruby
|
data/README.md
CHANGED
@@ -2,6 +2,19 @@
|
|
2
2
|
|
3
3
|
Real upsert for PostgreSQL 9.5+ and ActiveRecord. Uses ON CONFLICT DO UPDATE.
|
4
4
|
|
5
|
+
## Main points
|
6
|
+
|
7
|
+
- Does upsert on a single record using `ON CONFLICT DO UPDATE`
|
8
|
+
- Updates timestamps as you would expect in ActiveRecord
|
9
|
+
- For partial upserts, loads any existing data from the database
|
10
|
+
|
11
|
+
## Prerequisites
|
12
|
+
|
13
|
+
- PostgreSQL 9.5+
|
14
|
+
- ActiveRecord ~> 5
|
15
|
+
- For MRI: pg
|
16
|
+
- For JRuby: You need to use a fork of `activerecord-jdbcpostgresql-adapter`
|
17
|
+
|
5
18
|
## Installation
|
6
19
|
|
7
20
|
Add this line to your application's Gemfile:
|
@@ -10,6 +23,20 @@ Add this line to your application's Gemfile:
|
|
10
23
|
gem 'active_record_upsert'
|
11
24
|
```
|
12
25
|
|
26
|
+
If you use JRuby, also add the following:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
gem 'activerecord-jdbc-adapter',
|
30
|
+
github: 'jensnockert/activerecord-jdbc-adapter',
|
31
|
+
branch: 'activerecord-50',
|
32
|
+
platform: :jruby
|
33
|
+
|
34
|
+
gem 'activerecord-jdbcpostgresql-adapter',
|
35
|
+
github: 'jensnockert/activerecord-jdbc-adapter',
|
36
|
+
branch: 'activerecord-50',
|
37
|
+
platform: :jruby
|
38
|
+
```
|
39
|
+
|
13
40
|
And then execute:
|
14
41
|
|
15
42
|
$ bundle
|
@@ -42,3 +69,9 @@ r.upsert
|
|
42
69
|
|
43
70
|
Bug reports and pull requests are welcome on GitHub at https://github.com/jesjos/active_record_upsert.
|
44
71
|
|
72
|
+
## Contributors
|
73
|
+
|
74
|
+
- Jesper Josefsson
|
75
|
+
- Jens Nockert
|
76
|
+
- Olle Jonsson
|
77
|
+
- Simon Dahlbacka
|
@@ -8,8 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = ActiveRecordUpsert::VERSION
|
9
9
|
spec.authors = ["Jesper Josefsson"]
|
10
10
|
spec.email = ["jesper.josefsson@gmail.com"]
|
11
|
+
spec.homepage = "https://github.com/jesjos/active_record_upsert/"
|
11
12
|
|
12
|
-
spec.summary = %q{Real PostgreSQL upserts using ON CONFLICT for ActiveRecord}
|
13
|
+
spec.summary = %q{Real PostgreSQL 9.5+ upserts using ON CONFLICT for ActiveRecord}
|
13
14
|
|
14
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
16
|
spec.bindir = "exe"
|
@@ -24,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
24
25
|
spec.add_runtime_dependency 'activerecord-jdbcpostgresql-adapter', '> 0'
|
25
26
|
else
|
26
27
|
spec.platform = Gem::Platform::RUBY
|
27
|
-
spec.add_runtime_dependency 'pg', '
|
28
|
+
spec.add_runtime_dependency 'pg', '~> 0.18'
|
28
29
|
end
|
29
30
|
|
30
31
|
spec.add_development_dependency "bundler", "~> 1.11"
|
@@ -3,7 +3,8 @@ module ActiveRecordUpsert
|
|
3
3
|
module PersistenceExtensions
|
4
4
|
|
5
5
|
def upsert
|
6
|
-
raise ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
|
6
|
+
raise ::ActiveRecord::ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
|
7
|
+
raise ::ActiveRecord::RecordSavedError, "Can't upsert a record that has already been saved" if persisted?
|
7
8
|
values = run_callbacks(:save) {
|
8
9
|
run_callbacks(:create) {
|
9
10
|
_upsert_record
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_upsert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesper Josefsson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: pg
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '0.18'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '0.18'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,7 +158,7 @@ files:
|
|
158
158
|
- lib/active_record_upsert/arel/on_conflict_do_update_manager.rb
|
159
159
|
- lib/active_record_upsert/arel/visitors/to_sql.rb
|
160
160
|
- lib/active_record_upsert/version.rb
|
161
|
-
homepage:
|
161
|
+
homepage: https://github.com/jesjos/active_record_upsert/
|
162
162
|
licenses: []
|
163
163
|
metadata: {}
|
164
164
|
post_install_message:
|
@@ -180,5 +180,5 @@ rubyforge_project:
|
|
180
180
|
rubygems_version: 2.5.1
|
181
181
|
signing_key:
|
182
182
|
specification_version: 4
|
183
|
-
summary: Real PostgreSQL upserts using ON CONFLICT for ActiveRecord
|
183
|
+
summary: Real PostgreSQL 9.5+ upserts using ON CONFLICT for ActiveRecord
|
184
184
|
test_files: []
|